updating patternMatch func