Reworked the logic of time sync