Fix overlapping pattern matching