Only write when values have changed