Fixed logic error in calibration.