Sync script: refactoring 2