New function calc_formula