Fixing bugs with pattern matching