fixed end state bug