More performant pattern matching