cluster algoritm begin