compare before write