Fix error in optional state handling