Improved sync logic to prevent multiple refreshes