added sync logic