corrected calibration code