Replaced pattern matching with if.