splitting to add Kmeans
starting to add KMeans for speedup.