fix bugs in sync