refactoring and Kmedoids