move some functions to BasePattern class