implementing the centroid_distance logic. Not done yet