fix previous state bug