better KNN algorithm