Also, I would do this outside the generator, the code will be more logic