diff --git a/torch_modules/src/NumericColumnModule.cpp b/torch_modules/src/NumericColumnModule.cpp
index 8fb0ab33a0cf074810f9278750d737f97a042fad..21ea408dd335f6e189eff7993c8d9459c5ad0967 100644
--- a/torch_modules/src/NumericColumnModule.cpp
+++ b/torch_modules/src/NumericColumnModule.cpp
@@ -78,8 +78,11 @@ void NumericColumnModuleImpl::addToContext(std::vector<std::vector<long>> & cont
     {
       double res = 0.0;
       if (index >= 0)
-        try {res = std::stof(config.getAsFeature(column, index).get());}
+      {
+        auto value = config.getAsFeature(column, index).get();
+        try {res = std::stof(value);}
         catch (std::exception &) {res = defaultValue;}
+      }
 
       contextElement.emplace_back(0);
       std::memcpy(&contextElement.back(), &res, sizeof res);