fixed bug on centroids method