chaning all.vars(res$terms) to all.vars(formula)