Removing an if in place of pattern matching

I was thinking about this and figured it would be cleaner as pattern matching.