clustering using generator