refactor sync