fix distance calculation for kmeans