added clustering code