old version of merge clusters code