use flat_map
Merge pull request #11730 from neerajdotname/use_flat_map

use flat_map