successfully improved k-means script