proper restoration of the state for FSM