Centroid code in main