refactoring; adding k-means