diff --git a/lib/IdPAccountManager/WebRequest.pm b/lib/IdPAccountManager/WebRequest.pm
index f9060691f01a7aca37438f606dcc6335edc0ca6e..333eca04588249bd100fab845556ee08c8e09b89 100755
--- a/lib/IdPAccountManager/WebRequest.pm
+++ b/lib/IdPAccountManager/WebRequest.pm
@@ -12,6 +12,7 @@ use IdPAccountManager::Data::TestAccount;
 use IdPAccountManager::Data::AuthenticationToken;
 use IdPAccountManager::Data::ServiceProvider;
 use IdPAccountManager::SAMLMetadata;
+use IdPAccountManager::Tools;
 
 ## Defining parameters format
 my $urn_or_url_regex = '(http(s?):\/\/|urn:)[^\\\$\*\"\'\`\^\|\<\>\n\s]+'
@@ -214,7 +215,7 @@ sub req_account_wizard {
         return undef;
     }
 
-    $self->{out} = $metadata->parse();
+    $self->{out}->{metadata} = $metadata->parse();
 
     $self->{out}->{subtitle} = 'Select your Service Provider';
 
diff --git a/templates/web/select_sp.tt2.html b/templates/web/select_sp.tt2.html
index 0d178032130e56ac4531824fe28664bd74683763..03a7e36dda6cf90d92138e008c1e0f3e5eb4c133 100644
--- a/templates/web/select_sp.tt2.html
+++ b/templates/web/select_sp.tt2.html
@@ -2,14 +2,14 @@
 [% IF serviceprovider.displayname %]
 [% SET sp_display_name = serviceprovider.displayname %]
 [% ELSE %]
-[% SET sp_display_name = sp_metadata_as_hashref.entityid %]
+[% SET sp_display_name = metadata.entityid %]
 [% END %]
 <div>
 Before you can create test accounts at this Identity Provider, we need to ensure you are a legitimate administrator of "[% sp_display_name %]".
 </div>
 
 <fieldset class="scrollable">
-[% IF  sp_metadata_as_hashref.contacts.defined %]
+[% IF  metadata.contacts.defined %]
     <legend>Select your email address</legend>
    <label for="sp_entityid">The email addresses below have been extracted from your SP SAML metadata.<br/>Please select the email address where an email challenge
    can be sent to validate your identity</label>
@@ -19,7 +19,7 @@ Before you can create test accounts at this Identity Provider, we need to ensure
 [% FOREACH email IN serviceprovider.list_contacts_as_array.sort %]
 <input name="email_address" value="[% email %]" type="radio" class="required"/><label for="email_address">[% email %]</label><br/>
 
-<input type="hidden" name="sp_entityid" value="[% sp_metadata_as_hashref.entityid %]" id="sp_entityid"/>
+<input type="hidden" name="sp_entityid" value="[% metadata.entityid %]" id="sp_entityid"/>
 
 [% END %]
 </div>
@@ -38,4 +38,4 @@ administrator to add ContactPerson information to the SAML metadata.
           input.val([input.attr('value')]);
        });
     });
-</script>
\ No newline at end of file
+</script>