update clustering loop