Use pattern matching instead of RE