Refactoring #2: abstraction/extraction of clustering algorithm.