Reworked figure generation to have only one loop for generation