Only record changes when the state changed