What about just using `flat_map` here?