Corrected pattern matching