getting kmeans colors correctly with refactored code