diff --git a/src/Lib/Script/Ast/IrModule.cc b/src/Lib/Script/Ast/IrModule.cc
index dbeb2efd76cd4f1799fa4a2087923ade3e80e9e9..dfcfe6efc1a8832e16c96b323a492870ae753b24 100644
--- a/src/Lib/Script/Ast/IrModule.cc
+++ b/src/Lib/Script/Ast/IrModule.cc
@@ -120,16 +120,19 @@ IrModule::addImport(IrImport *importStatement)
 void
 IrModule::addOption(IrOption *obj)
 {
-    if (option(obj->name()) != nullptr)
+    if (option(obj->name()) == nullptr) {
         localOptions.push_back(obj);
-    else
-        throw std::runtime_error("Can't add multiple times an option with the same name");
+    } else {
+        throw std::runtime_error("Can't add multiple times an option with the same name, "
+                                 "duplicate name is: " +
+                                 obj->name().toStdString());
+    }
 }
 
 void
 IrModule::addFunction(IrFunction *obj)
 {
-    if (function(obj->name()) != nullptr)
+    if (function(obj->name()) == nullptr)
         localFunctions.push_back(obj);
     else
         throw std::runtime_error("Can't add multiple times an function with the same name");
@@ -138,7 +141,7 @@ IrModule::addFunction(IrFunction *obj)
 void
 IrModule::addJob(IrJob *obj)
 {
-    if (job(obj->name()) != nullptr)
+    if (job(obj->name()) == nullptr)
         localJobs.push_back(obj);
     else
         throw std::runtime_error("Can't add multiple times an job with the same name");