fix calibration function