bugfix in calc_var