refactored sync command