Got find_centroid function to work properly