fix pattern matching