Neighbour detection using grid layout