added countPatternLengths