isolate kmeans function