change kmeans to using lambda