Updated knn to work with partial distances