start to implement/refactor sync code