Changed maxDist of kNN to maxDist of k elements and added sqrt to the formula