You could just use `flat_map` here instead of `map` + `flatten`.