Use one match instead of mixture of if/match