Restructuring the generate method **