refine algorithm of circuit generation, optimizing the process of match pair generation (no need to regenerate match pairs for each mismatched pattern; instead, integrated in program.java)