diff --git a/src/core/agent.c b/src/core/agent.c
index b79638c8da76db838024f997813c15231ac1c768..138f2b8cca41eb9268649d7fbf4af976cb3f4d0f 100644
--- a/src/core/agent.c
+++ b/src/core/agent.c
@@ -3115,7 +3115,7 @@ void parse_scanresults(struct ubus_request *req, int type, struct blob_attr *msg
 		// if no neighbors, allocated
 		if (scanres_el->num_neighbors == 0) {
 			scanres_el->nbrlist = calloc(1, 1 * sizeof(*(scanres_el->nbrlist)));
-			if (!scanres_el)
+			if (!scanres_el->nbrlist)
 				continue;
 			scanres_el->num_neighbors++;
 		}
@@ -3127,7 +3127,8 @@ void parse_scanresults(struct ubus_request *req, int type, struct blob_attr *msg
 			if (nbr) {
 				scanres_el->num_neighbors++;
 				scanres_el->nbrlist = nbr;
-			}
+			} else
+				continue;
 		}
 		f = scanres_el->num_neighbors - 1; // fill index
 		// Fill in the neoghbour data