merged old changed to support patternfiles