fix bug in calc_off