adding clustering code