added pattern handling