adding code to enable backtracking over formulas