Fixed bug for centroid.