refactored kmeans.rb