make sure that we only write if data changed