fixed restore_state bug