Further abstraction of clustering algortihm #1