fix array in generateNeighborCoordinates
refactor generateNeighborCoordinates