handle reference loops in generator