added periodic recalibration code