using yield instead of return, and it works