fixed generator bug: fun with global variables