merge calibration code