successful version of ranking (kmeans)