Fixed bug in nearest neighbour.