clustering logic added. Reusable code generated