Added n nearest neighbour support