add sync and fix bugs