diff --git a/daemon/face/lp-reassembler.cpp b/daemon/face/lp-reassembler.cpp
index 77a7120..a4b255b 100644
--- a/daemon/face/lp-reassembler.cpp
+++ b/daemon/face/lp-reassembler.cpp
@@ -45,8 +45,6 @@
 {
   BOOST_ASSERT(packet.has<lp::FragmentField>());
 
-  static auto FALSE_RETURN = std::make_tuple(false, Block(), lp::Packet());
-
   // read and check FragIndex and FragCount
   uint64_t fragIndex = 0;
   uint64_t fragCount = 1;
@@ -59,12 +57,12 @@
 
   if (fragIndex >= fragCount) {
     NFD_LOG_FACE_WARN("reassembly error, FragIndex>=FragCount: DROP");
-    return FALSE_RETURN;
+    return {false, {}, {}};
   }
 
   if (fragCount > m_options.nMaxFragments) {
     NFD_LOG_FACE_WARN("reassembly error, FragCount over limit: DROP");
-    return FALSE_RETURN;
+    return {false, {}, {}};
   }
 
   // check for fast path
@@ -77,10 +75,11 @@
   // check Sequence and compute message identifier
   if (!packet.has<lp::SequenceField>()) {
     NFD_LOG_FACE_WARN("reassembly error, Sequence missing: DROP");
-    return FALSE_RETURN;
+    return {false, {}, {}};
   }
+
   lp::Sequence messageIdentifier = packet.get<lp::SequenceField>() - fragIndex;
-  Key key = std::make_tuple(remoteEndpoint, messageIdentifier);
+  Key key(remoteEndpoint, messageIdentifier);
 
   // add to PartialPacket
   PartialPacket& pp = m_partialPackets[key];
@@ -92,13 +91,13 @@
   else {
     if (fragCount != pp.fragCount) {
       NFD_LOG_FACE_WARN("reassembly error, FragCount changed: DROP");
-      return FALSE_RETURN;
+      return {false, {}, {}};
     }
   }
 
   if (pp.fragments[fragIndex].has<lp::SequenceField>()) {
     NFD_LOG_FACE_TRACE("fragment already received: DROP");
-    return FALSE_RETURN;
+    return {false, {}, {}};
   }
 
   pp.fragments[fragIndex] = packet;
@@ -109,13 +108,13 @@
     Block reassembled = doReassembly(key);
     lp::Packet firstFrag(std::move(pp.fragments[0]));
     m_partialPackets.erase(key);
-    return std::make_tuple(true, reassembled, firstFrag);
+    return {true, reassembled, firstFrag};
   }
 
   // set drop timer
   pp.dropTimer = getScheduler().schedule(m_options.reassemblyTimeout, [=] { timeoutPartialPacket(key); });
 
-  return FALSE_RETURN;
+  return {false, {}, {}};
 }
 
 Block
@@ -125,20 +124,16 @@
 
   size_t payloadSize = std::accumulate(pp.fragments.begin(), pp.fragments.end(), 0U,
     [&] (size_t sum, const lp::Packet& pkt) -> size_t {
-      ndn::Buffer::const_iterator fragBegin, fragEnd;
-      std::tie(fragBegin, fragEnd) = pkt.get<lp::FragmentField>();
+      auto [fragBegin, fragEnd] = pkt.get<lp::FragmentField>();
       return sum + std::distance(fragBegin, fragEnd);
     });
 
   ndn::Buffer fragBuffer(payloadSize);
   auto it = fragBuffer.begin();
-
   for (const lp::Packet& frag : pp.fragments) {
-    ndn::Buffer::const_iterator fragBegin, fragEnd;
-    std::tie(fragBegin, fragEnd) = frag.get<lp::FragmentField>();
+    auto [fragBegin, fragEnd] = frag.get<lp::FragmentField>();
     it = std::copy(fragBegin, fragEnd, it);
   }
-
   return Block(fragBuffer);
 }
 
