add mutex protection around the sync process