diff --git a/src/libnptm/Configuration.cpp b/src/libnptm/Configuration.cpp
index 252e76434f3111b20e19c43e362386eba27bcf46..fe78967c8e6a18705b076d266cd29fe4686c8f69 100644
--- a/src/libnptm/Configuration.cpp
+++ b/src/libnptm/Configuration.cpp
@@ -222,13 +222,18 @@ GeometryConfiguration* GeometryConfiguration::from_legacy(const std::string& fil
     throw ex;
   }
   int _nsph = 0, _lm = 0, _in_pol = 0, _npnt = 0, _npntts = 0, _isam = 0;
-  int _li = 0, _le = 0, _iavm = 0;
+  int _li = 0, _le = 0, _iavm = 0, num_params = 0;
   np_int _mxndm = 0;
   regex re = regex("-?[0-9]+");
+  str_target = file_lines[last_read_line];
+  while(regex_search(str_target, m, re)) {
+    str_target = m.suffix().str();
+    num_params++;
+  }
   str_target = file_lines[last_read_line++];
   regex_search(str_target, m, re);
   _nsph = stoi(m.str());
-  if (_nsph == 1) {
+  if (num_params == 6) {
     for (int ri = 0; ri < 5; ri++) {
       str_target = m.suffix().str();
       regex_search(str_target, m, re);
@@ -238,7 +243,7 @@ GeometryConfiguration* GeometryConfiguration::from_legacy(const std::string& fil
       if (ri == 3) _npntts = stoi(m.str());
       if (ri == 4) _isam = stoi(m.str());
     }
-  } else {
+  } else if (num_params == 9) {
     for (int ri = 0; ri < 8; ri++) {
       str_target = m.suffix().str();
       regex_search(str_target, m, re);
@@ -251,6 +256,9 @@ GeometryConfiguration* GeometryConfiguration::from_legacy(const std::string& fil
       if (ri == 6) _iavm = stoi(m.str());
       if (ri == 7) _isam = stoi(m.str());
     }
+  } else {
+    OpenConfigurationFileException ex("ERROR: " + file_name + " is not a recognized input file.");
+    throw ex;
   }
   double *x, *y, *z;
   x = new double[_nsph];
@@ -312,15 +320,14 @@ GeometryConfiguration* GeometryConfiguration::from_legacy(const std::string& fil
   regex_search(str_target, m, re);
   fjwtm = stoi(m.str());
   GeometryConfiguration *conf = new GeometryConfiguration(
-							  _nsph, _lm, _in_pol, _npnt, _npntts, _isam,
-							  _li, _le, _mxndm, _iavm,
-							  x, y, z,
-							  in_th_start, in_th_step, in_th_end,
-							  sc_th_start, sc_th_step, sc_th_end,
-							  in_ph_start, in_ph_step, in_ph_end,
-							  sc_ph_start, sc_ph_step, sc_ph_end,
-							  fjwtm
-							  );
+    _nsph, _lm, _in_pol, _npnt, _npntts, _isam,
+    _li, _le, _mxndm, _iavm, x, y, z,
+    in_th_start, in_th_step, in_th_end,
+    sc_th_start, sc_th_step, sc_th_end,
+    in_ph_start, in_ph_step, in_ph_end,
+    sc_ph_start, sc_ph_step, sc_ph_end,
+    fjwtm
+  );
   delete[] file_lines;
   return conf;
 }