trying to make the save() method atomic