Added centroid finding functions