Fixed the lost state logic a bit