fast version of knn_divs