repaired Kmeans, still a little slow