Updated version with new cluster matching algorithm