Error with pattern checking