implementing a sort of elbow method to detect the number of clusters