invalid state bug fix.