Update k-means implementation