generator is undefined at this point

Updated following comment from @SimonBoudrias