K-Means refactored