Reducing number of variables defined in generator