Fixing NearestNeighbour algorithm (work in progress)