bug fix in patternLength