more changes to k-means function