faster k-nearest computation