use map_failed everywhere