code for optimal no. of clusters