Added average centroid calculation