Adding clustering code