Fix bug in sync