Refactor to use flat_map