tweaked kmeans API