slight refactoring to generator