fix bug of state restore.