fixed indexing error in nearestNeighbors