Removed a redundant implementation of centroid calculation