bug fixes for knn