Use #flat_map instead of flatten#map