Use and_then instead of match