added pattern checking