added functionality for kmeans algorithm