Remove pattern matching nesting