updated sync logic