Corrected Pattern Matching problem