Making loop generator work