cycle as function, not generator