added random clustering code