better allocation in generator