fixed kmeans code matching function.