fixed previous state bug