diff --git a/src/factor/factor_base.cpp b/src/factor/factor_base.cpp
index 429379fe922e7d1cd663f30b8fa9634f374ce3cd..a0b4bc90005cb0ffa48c7ef21d87c758a7a52a36 100644
--- a/src/factor/factor_base.cpp
+++ b/src/factor/factor_base.cpp
@@ -315,29 +315,17 @@ void FactorBase::printHeader(int _depth, bool _constr_by, bool _metric, bool _st
         _stream << " Abs";
 
     for (const auto& Fow : getFrameOtherList())
-    {
-        auto Fow_sh = Fow.lock();
-        if (Fow_sh)
-            _stream << " Frm" << Fow_sh->id();
-    }
+        if (!Fow.expired())
+            _stream << " Frm" << Fow.lock()->id();
     for (const auto& Cow : getCaptureOtherList())
-    {
-        auto Cow_sh = Cow.lock();
-        if (Cow_sh)
-            _stream << " Cap" << Cow_sh->id();
-    }
+        if (!Cow.expired())
+            _stream << " Cap" << Cow.lock()->id();
     for (const auto& fow : getFeatureOtherList())
-    {
-        auto fow_sh = fow.lock();
-        if (fow_sh)
-            _stream << " Ftr" << fow_sh->id();
-    }
+        if (!fow.expired())
+            _stream << " Ftr" << fow.lock()->id();
     for (const auto& Low : getLandmarkOtherList())
-    {
-        auto Low_sh = Low.lock();
-        if (Low_sh)
-            _stream << " Lmk" << Low_sh->id();
-    }
+        if (!Low.expired())
+            _stream << " Lmk" << Low.lock()->id();
     _stream << std::endl;
 }