fix bugs for kmeans