check neighbour function