diff --git a/preprocessor/ModelTree.cc b/preprocessor/ModelTree.cc
index b0df567c94bd01a5516ccd9728f1c5a356209d99..eb7b3e118ab3e6ecbce1f989eb50c82329e20c8b 100644
--- a/preprocessor/ModelTree.cc
+++ b/preprocessor/ModelTree.cc
@@ -1296,6 +1296,8 @@ void
 ModelTree::fixNestedParenthesis(ostringstream &output, map<string, string> &tmp_paren_vars) const
 {
   string str = output.str();
+  if (!testNestedParenthesis(str))
+    return;
   int open = 0;
   int first_open_paren = 0;
   int matching_paren = 0;