diff --git a/libpldmresponder/base.cpp b/libpldmresponder/base.cpp
index 4d0c4f9..1071324 100644
--- a/libpldmresponder/base.cpp
+++ b/libpldmresponder/base.cpp
@@ -56,8 +56,12 @@
 
     Response response(sizeof(pldm_msg_hdr) + PLDM_GET_TYPES_RESP_BYTES, 0);
     auto responsePtr = reinterpret_cast<pldm_msg*>(response.data());
-    encode_get_types_resp(request->hdr.instance_id, PLDM_SUCCESS, types.data(),
-                          responsePtr);
+    auto rc = encode_get_types_resp(request->hdr.instance_id, PLDM_SUCCESS,
+                                    types.data(), responsePtr);
+    if (rc != PLDM_SUCCESS)
+    {
+        return CmdHandler::ccOnlyResponse(request, rc);
+    }
 
     return response;
 }
@@ -74,19 +78,15 @@
 
     if (rc != PLDM_SUCCESS)
     {
-        encode_get_commands_resp(request->hdr.instance_id, rc, nullptr,
-                                 responsePtr);
-        return response;
+        return CmdHandler::ccOnlyResponse(request, rc);
     }
 
     // DSP0240 has this as a bitfield8[N], where N = 0 to 31
     std::array<bitfield8_t, 32> cmds{};
     if (capabilities.find(type) == capabilities.end())
     {
-        encode_get_commands_resp(request->hdr.instance_id,
-                                 PLDM_ERROR_INVALID_PLDM_TYPE, nullptr,
-                                 responsePtr);
-        return response;
+        return CmdHandler::ccOnlyResponse(request,
+                                          PLDM_ERROR_INVALID_PLDM_TYPE);
     }
 
     for (const auto& cmd : capabilities.at(type))
@@ -97,8 +97,12 @@
         cmds[index].byte |= 1 << bit;
     }
 
-    encode_get_commands_resp(request->hdr.instance_id, PLDM_SUCCESS,
-                             cmds.data(), responsePtr);
+    rc = encode_get_commands_resp(request->hdr.instance_id, PLDM_SUCCESS,
+                                  cmds.data(), responsePtr);
+    if (rc != PLDM_SUCCESS)
+    {
+        return ccOnlyResponse(request, rc);
+    }
 
     return response;
 }
@@ -117,9 +121,7 @@
 
     if (rc != PLDM_SUCCESS)
     {
-        encode_get_version_resp(request->hdr.instance_id, rc, 0, 0, nullptr, 4,
-                                responsePtr);
-        return response;
+        return CmdHandler::ccOnlyResponse(request, rc);
     }
 
     ver32_t version{};
@@ -127,16 +129,18 @@
 
     if (search == versions.end())
     {
-        encode_get_version_resp(request->hdr.instance_id,
-                                PLDM_ERROR_INVALID_PLDM_TYPE, 0, 0, nullptr, 4,
-                                responsePtr);
-        return response;
+        return CmdHandler::ccOnlyResponse(request,
+                                          PLDM_ERROR_INVALID_PLDM_TYPE);
     }
 
     memcpy(&version, &(search->second), sizeof(version));
-    encode_get_version_resp(request->hdr.instance_id, PLDM_SUCCESS, 0,
-                            PLDM_START_AND_END, &version, sizeof(pldm_version),
-                            responsePtr);
+    rc = encode_get_version_resp(request->hdr.instance_id, PLDM_SUCCESS, 0,
+                                 PLDM_START_AND_END, &version,
+                                 sizeof(pldm_version), responsePtr);
+    if (rc != PLDM_SUCCESS)
+    {
+        return ccOnlyResponse(request, rc);
+    }
 
     return response;
 }
@@ -148,8 +152,12 @@
 
     Response response(sizeof(pldm_msg_hdr) + PLDM_GET_TID_RESP_BYTES, 0);
     auto responsePtr = reinterpret_cast<pldm_msg*>(response.data());
-    encode_get_tid_resp(request->hdr.instance_id, PLDM_SUCCESS, tid,
-                        responsePtr);
+    auto rc = encode_get_tid_resp(request->hdr.instance_id, PLDM_SUCCESS, tid,
+                                  responsePtr);
+    if (rc != PLDM_SUCCESS)
+    {
+        return ccOnlyResponse(request, rc);
+    }
 
     return response;
 }
diff --git a/libpldmresponder/bios.cpp b/libpldmresponder/bios.cpp
index 2d3a8ee..a92d3cd 100644
--- a/libpldmresponder/bios.cpp
+++ b/libpldmresponder/bios.cpp
@@ -157,10 +157,7 @@
         std::cerr << "Error getting time, PATH=" << hostTimePath
                   << " TIME INTERACE=" << timeInterface << "\n";
 
-        encode_get_date_time_resp(request->hdr.instance_id, PLDM_ERROR, seconds,
-                                  minutes, hours, day, month, year,
-                                  responsePtr);
-        return response;
+        return CmdHandler::ccOnlyResponse(request, PLDM_ERROR);
     }
 
     uint64_t timeSec = std::chrono::duration_cast<std::chrono::seconds>(
@@ -170,8 +167,14 @@
     pldm::responder::utils::epochToBCDTime(timeSec, seconds, minutes, hours,
                                            day, month, year);
 
-    encode_get_date_time_resp(request->hdr.instance_id, PLDM_SUCCESS, seconds,
-                              minutes, hours, day, month, year, responsePtr);
+    auto rc = encode_get_date_time_resp(request->hdr.instance_id, PLDM_SUCCESS,
+                                        seconds, minutes, hours, day, month,
+                                        year, responsePtr);
+    if (rc != PLDM_SUCCESS)
+    {
+        return ccOnlyResponse(request, rc);
+    }
+
     return response;
 }
 
@@ -221,15 +224,10 @@
 
 /** @brief Construct the BIOS string table
  *
- *  @param[in] BIOSStringTable - the string table
- *  @param[in] transferHandle - transfer handle to identify part of transfer
- *  @param[in] transferOpFlag - flag to indicate which part of data being
- * transferred
- *  @param[in] instanceID - instance ID to identify the command
+ *  @param[in,out] BIOSStringTable - the string table
+ *  @param[in] request - Request message
  */
-Response getBIOSStringTable(BIOSTable& BIOSStringTable,
-                            uint32_t /*transferHandle*/,
-                            uint8_t /*transferOpFlag*/, uint8_t instanceID)
+Response getBIOSStringTable(BIOSTable& BIOSStringTable, const pldm_msg* request)
 
 {
     Response response(sizeof(pldm_msg_hdr) + PLDM_GET_BIOS_TABLE_MIN_RESP_BYTES,
@@ -237,10 +235,16 @@
     auto responsePtr = reinterpret_cast<pldm_msg*>(response.data());
     if (!BIOSStringTable.isEmpty())
     {
-        encode_get_bios_table_resp(instanceID, PLDM_SUCCESS,
-                                   0, /* next transfer handle */
-                                   PLDM_START_AND_END, nullptr, response.size(),
-                                   responsePtr); // filling up the header here
+        auto rc = encode_get_bios_table_resp(
+            request->hdr.instance_id, PLDM_SUCCESS,
+            0, /* next transfer handle */
+            PLDM_START_AND_END, nullptr, response.size(),
+            responsePtr); // filling up the header here
+        if (rc != PLDM_SUCCESS)
+        {
+            return CmdHandler::ccOnlyResponse(request, rc);
+        }
+
         BIOSStringTable.load(response);
         return response;
     }
@@ -279,9 +283,14 @@
                         stringTable.size(),
                     0);
     responsePtr = reinterpret_cast<pldm_msg*>(response.data());
-    encode_get_bios_table_resp(
-        instanceID, PLDM_SUCCESS, 0 /* nxtTransferHandle */, PLDM_START_AND_END,
-        stringTable.data(), response.size(), responsePtr);
+    auto rc = encode_get_bios_table_resp(
+        request->hdr.instance_id, PLDM_SUCCESS, 0 /* nxtTransferHandle */,
+        PLDM_START_AND_END, stringTable.data(), response.size(), responsePtr);
+    if (rc != PLDM_SUCCESS)
+    {
+        return CmdHandler::ccOnlyResponse(request, rc);
+    }
+
     return response;
 }
 
@@ -697,19 +706,14 @@
 
 /** @brief Construct the BIOS attribute table
  *
- *  @param[in] BIOSAttributeTable - the attribute table
+ *  @param[in,out] BIOSAttributeTable - the attribute table
  *  @param[in] BIOSStringTable - the string table
- *  @param[in] transferHandle - transfer handle to identify part of transfer
- *  @param[in] transferOpFlag - flag to indicate which part of data being
- * transferred
- *  @param[in] instanceID - instance ID to identify the command
  *  @param[in] biosJsonDir - path where the BIOS json files are present
+ *  @param[in] request - Request message
  */
 Response getBIOSAttributeTable(BIOSTable& BIOSAttributeTable,
                                const BIOSTable& BIOSStringTable,
-                               uint32_t /*transferHandle*/,
-                               uint8_t /*transferOpFlag*/, uint8_t instanceID,
-                               const char* biosJsonDir)
+                               const char* biosJsonDir, const pldm_msg* request)
 {
     Response response(sizeof(pldm_msg_hdr) + PLDM_GET_BIOS_TABLE_MIN_RESP_BYTES,
                       0);
@@ -734,10 +738,8 @@
 
         if (attributeTable.empty())
         { // no available json file is found
-            encode_get_bios_table_resp(instanceID, PLDM_BIOS_TABLE_UNAVAILABLE,
-                                       nxtTransferHandle, transferFlag, nullptr,
-                                       response.size(), responsePtr);
-            return response;
+            return CmdHandler::ccOnlyResponse(request,
+                                              PLDM_BIOS_TABLE_UNAVAILABLE);
         }
         pldm::responder::utils::padAndChecksum(attributeTable);
         BIOSAttributeTable.store(attributeTable);
@@ -745,15 +747,25 @@
                         PLDM_GET_BIOS_TABLE_MIN_RESP_BYTES +
                         attributeTable.size());
         responsePtr = reinterpret_cast<pldm_msg*>(response.data());
-        encode_get_bios_table_resp(instanceID, PLDM_SUCCESS, nxtTransferHandle,
-                                   transferFlag, attributeTable.data(),
-                                   response.size(), responsePtr);
+
+        auto rc = encode_get_bios_table_resp(
+            request->hdr.instance_id, PLDM_SUCCESS, nxtTransferHandle,
+            transferFlag, attributeTable.data(), response.size(), responsePtr);
+        if (rc != PLDM_SUCCESS)
+        {
+            return CmdHandler::ccOnlyResponse(request, rc);
+        }
     }
     else
     { // persisted table present, constructing response
-        encode_get_bios_table_resp(instanceID, PLDM_SUCCESS, nxtTransferHandle,
-                                   transferFlag, nullptr, response.size(),
-                                   responsePtr); // filling up the header here
+        auto rc = encode_get_bios_table_resp(
+            request->hdr.instance_id, PLDM_SUCCESS, nxtTransferHandle,
+            transferFlag, nullptr, response.size(),
+            responsePtr); // filling up the header here
+        if (rc != PLDM_SUCCESS)
+        {
+            return CmdHandler::ccOnlyResponse(request, rc);
+        }
         BIOSAttributeTable.load(response);
     }
 
@@ -796,20 +808,15 @@
 
 /** @brief Construct the BIOS attribute value table
  *
- *  @param[in] BIOSAttributeValueTable - the attribute value table
+ *  @param[in,out] BIOSAttributeValueTable - the attribute value table
  *  @param[in] BIOSAttributeTable - the attribute table
  *  @param[in] BIOSStringTable - the string table
- *  @param[in] transferHandle - transfer handle to identify part of transfer
- *  @param[in] transferOpFlag - flag to indicate which part of data being
- * transferred
- *  @param[in] instanceID - instance ID to identify the command
+ *  @param[in] request - Request message
  */
 Response getBIOSAttributeValueTable(BIOSTable& BIOSAttributeValueTable,
                                     const BIOSTable& BIOSAttributeTable,
                                     const BIOSTable& BIOSStringTable,
-                                    uint32_t& /*transferHandle*/,
-                                    uint8_t& /*transferOpFlag*/,
-                                    uint8_t instanceID)
+                                    const pldm_msg* request)
 {
     Response response(sizeof(pldm_msg_hdr) + PLDM_GET_BIOS_TABLE_MIN_RESP_BYTES,
                       0);
@@ -819,9 +826,15 @@
 
     if (!BIOSAttributeValueTable.isEmpty())
     {
-        encode_get_bios_table_resp(instanceID, PLDM_SUCCESS, nxtTransferHandle,
-                                   transferFlag, nullptr, response.size(),
-                                   responsePtr); // filling up the header here
+        auto rc = encode_get_bios_table_resp(
+            request->hdr.instance_id, PLDM_SUCCESS, nxtTransferHandle,
+            transferFlag, nullptr, response.size(),
+            responsePtr); // filling up the header here
+        if (rc != PLDM_SUCCESS)
+        {
+            return CmdHandler::ccOnlyResponse(request, rc);
+        }
+
         BIOSAttributeValueTable.load(response);
         return response;
     }
@@ -838,10 +851,7 @@
         });
     if (attributeValueTable.empty())
     {
-        encode_get_bios_table_resp(instanceID, PLDM_BIOS_TABLE_UNAVAILABLE,
-                                   nxtTransferHandle, transferFlag, nullptr,
-                                   response.size(), responsePtr);
-        return response;
+        return CmdHandler::ccOnlyResponse(request, PLDM_BIOS_TABLE_UNAVAILABLE);
     }
     pldm::responder::utils::padAndChecksum(attributeValueTable);
     BIOSAttributeValueTable.store(attributeValueTable);
@@ -849,9 +859,13 @@
     response.resize(sizeof(pldm_msg_hdr) + PLDM_GET_BIOS_TABLE_MIN_RESP_BYTES +
                     attributeValueTable.size());
     responsePtr = reinterpret_cast<pldm_msg*>(response.data());
-    encode_get_bios_table_resp(instanceID, PLDM_SUCCESS, nxtTransferHandle,
-                               transferFlag, attributeValueTable.data(),
-                               response.size(), responsePtr);
+    auto rc = encode_get_bios_table_resp(
+        request->hdr.instance_id, PLDM_SUCCESS, nxtTransferHandle, transferFlag,
+        attributeValueTable.data(), response.size(), responsePtr);
+    if (rc != PLDM_SUCCESS)
+    {
+        return CmdHandler::ccOnlyResponse(request, rc);
+    }
 
     return response;
 }
@@ -930,9 +944,13 @@
                           valueLength,
                       0);
     auto responsePtr = reinterpret_cast<pldm_msg*>(response.data());
-    encode_get_bios_current_value_by_handle_resp(
+    rc = encode_get_bios_current_value_by_handle_resp(
         request->hdr.instance_id, PLDM_SUCCESS, 0, PLDM_START_AND_END, valuePtr,
         valueLength, responsePtr);
+    if (rc != PLDM_SUCCESS)
+    {
+        return ccOnlyResponse(request, rc);
+    }
 
     return response;
 }
@@ -945,15 +963,10 @@
 {
     Response response(sizeof(pldm_msg_hdr) + PLDM_GET_BIOS_TABLE_MIN_RESP_BYTES,
                       0);
-    auto responsePtr = reinterpret_cast<pldm_msg*>(response.data());
 
     if (setupConfig(biosJsonDir) != 0)
     {
-        encode_get_bios_table_resp(
-            request->hdr.instance_id, PLDM_BIOS_TABLE_UNAVAILABLE,
-            0 /* nxtTransferHandle */, PLDM_START_AND_END, nullptr,
-            response.size(), responsePtr);
-        return response;
+        return CmdHandler::ccOnlyResponse(request, PLDM_BIOS_TABLE_UNAVAILABLE);
     }
 
     uint32_t transferHandle{};
@@ -962,63 +975,55 @@
 
     auto rc = decode_get_bios_table_req(request, payloadLength, &transferHandle,
                                         &transferOpFlag, &tableType);
-    if (rc == PLDM_SUCCESS)
+    if (rc != PLDM_SUCCESS)
     {
-        BIOSTable BIOSStringTable(
-            (std::string(biosTablePath) + "/" + stringTableFile).c_str());
-        BIOSTable BIOSAttributeTable(
-            (std::string(biosTablePath) + "/" + attrTableFile).c_str());
-        BIOSTable BIOSAttributeValueTable(
-            (std::string(biosTablePath) + "/" + attrValTableFile).c_str());
-        switch (tableType)
-        {
-            case PLDM_BIOS_STRING_TABLE:
+        return CmdHandler::ccOnlyResponse(request, rc);
+    }
 
-                response = getBIOSStringTable(BIOSStringTable, transferHandle,
-                                              transferOpFlag,
-                                              request->hdr.instance_id);
-                break;
-            case PLDM_BIOS_ATTR_TABLE:
+    BIOSTable BIOSStringTable(
+        (std::string(biosTablePath) + "/" + stringTableFile).c_str());
+    BIOSTable BIOSAttributeTable(
+        (std::string(biosTablePath) + "/" + attrTableFile).c_str());
+    BIOSTable BIOSAttributeValueTable(
+        (std::string(biosTablePath) + "/" + attrValTableFile).c_str());
+    switch (tableType)
+    {
+        case PLDM_BIOS_STRING_TABLE:
 
-                if (BIOSStringTable.isEmpty())
-                {
-                    rc = PLDM_BIOS_TABLE_UNAVAILABLE;
-                }
-                else
-                {
-                    response = getBIOSAttributeTable(
-                        BIOSAttributeTable, BIOSStringTable, transferHandle,
-                        transferOpFlag, request->hdr.instance_id, biosJsonDir);
-                }
-                break;
-            case PLDM_BIOS_ATTR_VAL_TABLE:
-                if (BIOSAttributeTable.isEmpty() || BIOSStringTable.isEmpty())
-                {
-                    rc = PLDM_BIOS_TABLE_UNAVAILABLE;
-                }
-                else
-                {
-                    response = getBIOSAttributeValueTable(
-                        BIOSAttributeValueTable, BIOSAttributeTable,
-                        BIOSStringTable, transferHandle, transferOpFlag,
-                        request->hdr.instance_id);
-                }
-                break;
-            default:
-                rc = PLDM_INVALID_BIOS_TABLE_TYPE;
-                break;
-        }
+            response = getBIOSStringTable(BIOSStringTable, request);
+            break;
+        case PLDM_BIOS_ATTR_TABLE:
+
+            if (BIOSStringTable.isEmpty())
+            {
+                rc = PLDM_BIOS_TABLE_UNAVAILABLE;
+            }
+            else
+            {
+                response = getBIOSAttributeTable(
+                    BIOSAttributeTable, BIOSStringTable, biosJsonDir, request);
+            }
+            break;
+        case PLDM_BIOS_ATTR_VAL_TABLE:
+            if (BIOSAttributeTable.isEmpty() || BIOSStringTable.isEmpty())
+            {
+                rc = PLDM_BIOS_TABLE_UNAVAILABLE;
+            }
+            else
+            {
+                response = getBIOSAttributeValueTable(BIOSAttributeValueTable,
+                                                      BIOSAttributeTable,
+                                                      BIOSStringTable, request);
+            }
+            break;
+        default:
+            rc = PLDM_INVALID_BIOS_TABLE_TYPE;
+            break;
     }
 
     if (rc != PLDM_SUCCESS)
     {
-        uint32_t nxtTransferHandle{};
-        uint8_t transferFlag{};
-        size_t respPayloadLength{};
-
-        encode_get_bios_table_resp(request->hdr.instance_id, rc,
-                                   nxtTransferHandle, transferFlag, nullptr,
-                                   respPayloadLength, responsePtr);
+        return CmdHandler::ccOnlyResponse(request, rc);
     }
 
     return response;
diff --git a/libpldmresponder/platform.cpp b/libpldmresponder/platform.cpp
index 9c5b688..3f93ff4 100644
--- a/libpldmresponder/platform.cpp
+++ b/libpldmresponder/platform.cpp
@@ -19,9 +19,7 @@
 
     if (payloadLength != PLDM_GET_PDR_REQ_BYTES)
     {
-        encode_get_pdr_resp(request->hdr.instance_id, PLDM_ERROR_INVALID_LENGTH,
-                            0, 0, 0, 0, nullptr, 0, responsePtr);
-        return response;
+        return CmdHandler::ccOnlyResponse(request, PLDM_ERROR_INVALID_LENGTH);
     }
 
     uint32_t recordHandle{};
@@ -30,9 +28,13 @@
     uint16_t reqSizeBytes{};
     uint16_t recordChangeNum{};
 
-    decode_get_pdr_req(request, payloadLength, &recordHandle,
-                       &dataTransferHandle, &transferOpFlag, &reqSizeBytes,
-                       &recordChangeNum);
+    auto rc = decode_get_pdr_req(request, payloadLength, &recordHandle,
+                                 &dataTransferHandle, &transferOpFlag,
+                                 &reqSizeBytes, &recordChangeNum);
+    if (rc != PLDM_SUCCESS)
+    {
+        return CmdHandler::ccOnlyResponse(request, rc);
+    }
 
     uint32_t nextRecordHandle{};
     uint16_t respSizeBytes{};
@@ -56,26 +58,24 @@
                             respSizeBytes,
                         0);
         responsePtr = reinterpret_cast<pldm_msg*>(response.data());
-        encode_get_pdr_resp(request->hdr.instance_id, PLDM_SUCCESS,
-                            nextRecordHandle, 0, PLDM_START, respSizeBytes,
-                            recordData, 0, responsePtr);
+        rc = encode_get_pdr_resp(request->hdr.instance_id, PLDM_SUCCESS,
+                                 nextRecordHandle, 0, PLDM_START, respSizeBytes,
+                                 recordData, 0, responsePtr);
+        if (rc != PLDM_SUCCESS)
+        {
+            return ccOnlyResponse(request, rc);
+        }
     }
     catch (const std::out_of_range& e)
     {
-        encode_get_pdr_resp(request->hdr.instance_id,
-                            PLDM_PLATFORM_INVALID_RECORD_HANDLE,
-                            nextRecordHandle, 0, PLDM_START, respSizeBytes,
-                            recordData, 0, responsePtr);
-        return response;
+        return CmdHandler::ccOnlyResponse(request,
+                                          PLDM_PLATFORM_INVALID_RECORD_HANDLE);
     }
     catch (const std::exception& e)
     {
         std::cerr << "Error accessing PDR, HANDLE=" << recordHandle
                   << " ERROR=" << e.what() << "\n";
-        encode_get_pdr_resp(request->hdr.instance_id, PLDM_ERROR,
-                            nextRecordHandle, 0, PLDM_START, respSizeBytes,
-                            recordData, 0, responsePtr);
-        return response;
+        return CmdHandler::ccOnlyResponse(request, PLDM_ERROR);
     }
     return response;
 }
@@ -96,26 +96,34 @@
         (payloadLength < sizeof(effecterId) + sizeof(compEffecterCnt) +
                              sizeof(set_effecter_state_field)))
     {
-        encode_set_state_effecter_states_resp(
-            request->hdr.instance_id, PLDM_ERROR_INVALID_LENGTH, responsePtr);
-        return response;
+        return CmdHandler::ccOnlyResponse(request, PLDM_ERROR_INVALID_LENGTH);
     }
 
     int rc = decode_set_state_effecter_states_req(request, payloadLength,
                                                   &effecterId, &compEffecterCnt,
                                                   stateField.data());
 
-    if (rc == PLDM_SUCCESS)
+    if (rc != PLDM_SUCCESS)
     {
-        stateField.resize(compEffecterCnt);
-
-        const pldm::utils::DBusHandler dBusIntf;
-        rc = setStateEffecterStatesHandler<pldm::utils::DBusHandler>(
-            dBusIntf, effecterId, stateField);
+        return CmdHandler::ccOnlyResponse(request, rc);
     }
 
-    encode_set_state_effecter_states_resp(request->hdr.instance_id, rc,
-                                          responsePtr);
+    stateField.resize(compEffecterCnt);
+    const pldm::utils::DBusHandler dBusIntf;
+    rc = setStateEffecterStatesHandler<pldm::utils::DBusHandler>(
+        dBusIntf, effecterId, stateField);
+    if (rc != PLDM_SUCCESS)
+    {
+        return CmdHandler::ccOnlyResponse(request, rc);
+    }
+
+    rc = encode_set_state_effecter_states_resp(request->hdr.instance_id, rc,
+                                               responsePtr);
+    if (rc != PLDM_SUCCESS)
+    {
+        return ccOnlyResponse(request, rc);
+    }
+
     return response;
 }
 
