replaced *pattern & *lastPattern with *varsListPattner & *inputPattern