updated the clustering algorithm