fixed calibrate function