added centroid computation