updated calibration code