Use match instead of if else chain