Improve performance of clustering