Separated loop to find best center into function so it can be used in k-means++