diff --git a/attn/attn_logging.cpp b/attn/attn_logging.cpp
index a88a85e..3141130 100644
--- a/attn/attn_logging.cpp
+++ b/attn/attn_logging.cpp
@@ -108,14 +108,28 @@
 
     // The additional data contains the TI info as well as the value for the
     // subystem that provided the TI info. Get the subystem from additional
-    // data and then populate the prmary SRC and SRC words for the custom PEL
-    // based on the sybsystem's TI info.
-    uint8_t subsystem = std::stoi(i_additional["Subsystem"]);
-    tiPel->setSubsystem(subsystem);
+    // data and then populate the primary SRC and SRC words for the custom PEL
+    // based on the subsystem's TI info.
+    std::map<std::string, std::string>::iterator it;
+    uint8_t subsystem;
+
+    it = i_additional.find("Subsystem");
+    if (it != i_additional.end())
+    {
+        subsystem = std::stoi(it->second);
+        tiPel->setSubsystem(subsystem);
+    }
+    else
+    {
+        // The entry with key "Subsystem" does not exist in the additional map.
+        // Log the error, create failure event, and return.
+        trace::err("Error the key %s does not exist in the map.", "Subsystem");
+        eventAttentionFail((int)AttnSection::attnLogging | ATTN_INVALID_KEY);
+        return;
+    }
 
     // If recoverable attentions are active we will call the analyzer and
     // then link the custom pel to analyzer pel.
-    std::map<std::string, std::string>::iterator it;
     it = i_additional.find("recoverables");
     if (it != i_additional.end() && "true" == it->second)
     {
@@ -146,9 +160,24 @@
 
         // char array for raw pel src
         std::array<char, pel::asciiStringSize> srcChars{'0'};
+        std::string srcString;
 
         // src from TI info
-        std::string srcString = i_additional["SrcAscii"];
+        it = i_additional.find("SrcAscii");
+        if (it != i_additional.end())
+        {
+            srcString = it->second;
+        }
+        else
+        {
+            // The entry with key "Subsystem" does not exist in the additional
+            // map. Log the error, create failure event, and return.
+            trace::err("Error the key %s does not exist in the map.",
+                       "SrcAscii");
+            eventAttentionFail((int)AttnSection::attnLogging |
+                               ATTN_INVALID_KEY);
+            return;
+        }
 
         // copy from string to char array
         srcString.copy(srcChars.data(),
@@ -157,7 +186,7 @@
         tiPel->setAsciiString(srcChars); // pel object src is char array
 
         // set symptom-id
-        auto symptomId = (i_additional["SrcAscii"].substr(0, 8) + '_');
+        auto symptomId = (srcString.substr(0, 8) + '_');
 
         symptomId += (i_additional["0x10 SRC Word 12"]);
         symptomId += (i_additional["0x14 SRC Word 13"] + '_');
@@ -191,9 +220,24 @@
 
         // char array for raw pel src
         std::array<char, pel::asciiStringSize> srcChars{'0'};
+        std::string srcString;
 
         // src from TI info
-        std::string srcString = i_additional["SrcAscii"];
+        it = i_additional.find("SrcAscii");
+        if (it != i_additional.end())
+        {
+            srcString = it->second;
+        }
+        else
+        {
+            // The entry with key "Subsystem" does not exist in the additional
+            // map. Log the error, create failure event, and return.
+            trace::err("Error the key %s does not exist in the map.",
+                       "SrcAscii");
+            eventAttentionFail((int)AttnSection::attnLogging |
+                               ATTN_INVALID_KEY);
+            return;
+        }
 
         // copy from string to char array
         srcString.copy(srcChars.data(),
@@ -202,7 +246,7 @@
         tiPel->setAsciiString(srcChars); // pel object src is char array
 
         // set symptom-id
-        auto symptomId = (i_additional["SrcAscii"].substr(0, 8) + '_');
+        auto symptomId = (srcString.substr(0, 8) + '_');
 
         symptomId += (i_additional["0x10 HB Word 0"]);       // note: word 1
         symptomId += (i_additional["0x14 HB Word 2"] + '_'); // does not exist
@@ -334,7 +378,25 @@
                 close(pelFd);
             }
 
-            uint8_t subsystem = std::stoi(i_additional["Subsystem"]);
+            std::map<std::string, std::string>::iterator it;
+            uint8_t subsystem;
+
+            it = i_additional.find("Subsystem");
+            if (it != i_additional.end())
+            {
+                subsystem = std::stoi(it->second);
+            }
+            else
+            {
+                // The entry with key "Subsystem" does not exist in the
+                // additional map. Log the error, create failure event, and
+                // return.
+                trace::err("Error the key %s does not exist in the map.",
+                           "Subsystem");
+                eventAttentionFail((int)AttnSection::attnLogging |
+                                   ATTN_INVALID_KEY);
+                return 0;
+            }
 
             // If not hypervisor TI
             if (static_cast<uint8_t>(pel::SubsystemID::hypervisor) != subsystem)
@@ -370,7 +432,24 @@
     {
         tiInfoSize = 56; // assume not hypervisor TI
 
-        uint8_t subsystem = std::stoi(i_additionalData["Subsystem"]);
+        std::map<std::string, std::string>::iterator it;
+        uint8_t subsystem;
+
+        it = i_additionalData.find("Subsystem");
+        if (it != i_additionalData.end())
+        {
+            subsystem = std::stoi(it->second);
+        }
+        else
+        {
+            // The entry with key "Subsystem" does not exist in the additional
+            // map. Log the error, create failure event, and return.
+            trace::err("Error the key %s does not exist in the map.",
+                       "Subsystem");
+            eventAttentionFail((int)AttnSection::attnLogging |
+                               ATTN_INVALID_KEY);
+            return;
+        }
 
         // If hypervisor
         if (static_cast<uint8_t>(pel::SubsystemID::hypervisor) == subsystem)
