add save centroids code