diff --git a/lib/SimpleSAML/XML/Shib13/AuthnResponse.php b/lib/SimpleSAML/XML/Shib13/AuthnResponse.php
index 4c1db92d691947853f7f97bb1273508d447d6966..0e711ce5b3acacb80fa40b69b0be0fd7fc5ac609 100644
--- a/lib/SimpleSAML/XML/Shib13/AuthnResponse.php
+++ b/lib/SimpleSAML/XML/Shib13/AuthnResponse.php
@@ -254,6 +254,8 @@ class SimpleSAML_XML_Shib13_AuthnResponse extends SimpleSAML_XML_AuthnResponse {
 						// Traverse Values
 						foreach ($attribute->AttributeValue AS $newvalue) {
 						
+							$newvalue = (string)$newvalue;
+
 							if ($base64) {
 								$encodedvalues = explode('_', $newvalue);
 								foreach($encodedvalues AS $v) {
@@ -263,8 +265,6 @@ class SimpleSAML_XML_Shib13_AuthnResponse extends SimpleSAML_XML_AuthnResponse {
 
 								$values[] = $newvalue;
 							}
-						
-							$values[] = (string) $val;
 						}
 						
 						$attributes[(string)$attribute['AttributeName']] = $values;