corrected a BIG bug in pattern matching