implement clustering