refactored with concatenatePatternFuncs