PatternBuilder refactor