Added neighbour detection that is boundary aware