Updated Autocalibration function