changing code to take max sim from every cluster