fixing bug in data sync logic