sanitized kmeans code