a generative approach with yield