use current and new value in write_if calculation
Merge pull request #4 from timsly/better-write-if

Use current and new value in write_if calculation