diff --git a/src/bbf_plugin/hosts.c b/src/bbf_plugin/hosts.c
index 01324b134d28799da8f86e5b379680e621db3d44..21a11b3223d71e40246b7a2e4a0602c00d5e7f14 100644
--- a/src/bbf_plugin/hosts.c
+++ b/src/bbf_plugin/hosts.c
@@ -41,11 +41,16 @@ static int host_get_last_instance(void)
 static void synchronize_hosts_array_with_dmmap(json_object *res)
 {
 	struct uci_section *s = NULL, *stmp = NULL;
+	json_object *hosts_arr = NULL;
 	char *mac = NULL, *host_mac = NULL;
 	bool host_read_idx = false;
 	int host_idx = 0;
 
-	size_t nbre_hosts = (res) ? json_object_array_length(res) : 0;
+	if (!res)
+		return;
+
+	json_object_object_get_ex(res, "hosts", &hosts_arr);
+	int nbre_hosts = (hosts_arr) ? json_object_array_length(hosts_arr) : 0;
 
 	uci_path_foreach_sections_safe(bbfdm, "dmmap_hosts", "host", stmp, s) {
 
@@ -53,7 +58,7 @@ static void synchronize_hosts_array_with_dmmap(json_object *res)
 
 		if (host_idx < nbre_hosts) {
 			if (!host_read_idx) {
-				json_object *host_obj = json_object_array_get_idx(res, host_idx);
+				json_object *host_obj = json_object_array_get_idx(hosts_arr, host_idx);
 				host_mac = dmjson_get_value(host_obj, 1, "macaddr");
 				host_read_idx = true;
 			}