fix bug at end of sync