complete k-means main function