diff --git a/modules/core/www/idp/logout-iframe.php b/modules/core/www/idp/logout-iframe.php
index 547d86a1048c2a91dd5fbbfd008cbe11f44bf57a..53f4a637363e694e00630e498b6c214753a00620 100644
--- a/modules/core/www/idp/logout-iframe.php
+++ b/modules/core/www/idp/logout-iframe.php
@@ -112,22 +112,21 @@ foreach ($state['core:Logout-IFrame:Associations'] as $association) {
     }
 }
 
-$id = \SimpleSAML\Auth\State::saveState($state, 'core:Logout-IFrame');
 $globalConfig = \SimpleSAML\Configuration::getInstance();
-
-$template_id = 'core:logout-iframe.php';
 if ($type === 'nojs') {
-    $template_id = 'core:logout-iframe-wrapper.php';
+    $t = new \SimpleSAML\XHTML\Template($globalConfig, 'core:logout-iframe-wrapper.php');
+} else {
+    $t = new \SimpleSAML\XHTML\Template($globalConfig, 'core:logout-iframe.php');
 }
 
-$t = new \SimpleSAML\XHTML\Template($globalConfig, $template_id);
-$t->data['auth_state'] = $id;
-$t->data['header'] = $t->getTranslator()->t('{logout:progress}');
-
 /**
  * @deprecated The "id" variable will be removed. Please use "auth_state" instead.
  */
+$id = \SimpleSAML\Auth\State::saveState($state, 'core:Logout-IFrame');
 $t->data['id'] = $id;
+$t->data['auth_state'] = $id;
+
+$t->data['header'] = $t->getTranslator()->t('{logout:progress}');
 $t->data['type'] = $type;
 $t->data['terminated_service'] = $terminated;
 $t->data['remaining_services'] = $remaining;