Index: /branches/end_stage/ippTools/src/regtool.c
===================================================================
--- /branches/end_stage/ippTools/src/regtool.c	(revision 16050)
+++ /branches/end_stage/ippTools/src/regtool.c	(revision 16051)
@@ -813,5 +813,37 @@
 
     bool status = false;
-    // required
+    psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id");
+        return false;
+    }
+    if (!exp_id) {
+        psError(PS_ERR_UNKNOWN, true, "-exp_id is required");
+        return false;
+    }
+
+    bool detrend = psMetadataLookupBool(&status, config->args, "-detrend");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -detrend");
+        return false;
+    }
+
+    psString dvodb = psMetadataLookupStr(&status, config->args, "-dvodb");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -dvodb");
+        return false;
+    }
+
+    psString tess_id = psMetadataLookupStr(&status, config->args, "-tess_id");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -tess_id");
+        return false;
+    }
+
+    psString end_stage = psMetadataLookupStr(&status, config->args, "-end_stage");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -end_stage");
+        return false;
+    }
     psString exp_name = psMetadataLookupStr(&status, config->args, "-exp_name");
     if (!status) {
@@ -1128,37 +1160,4 @@
     if (!status) {
         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -code");
-        return false;
-    }
-    psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id");
-        return false;
-    }
-    if (!exp_id) {
-        psError(PS_ERR_UNKNOWN, true, "-exp_id is required");
-        return false;
-    }
-
-    bool detrend = psMetadataLookupBool(&status, config->args, "-detrend");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -detrend");
-        return false;
-    }
-
-    psString dvodb = psMetadataLookupStr(&status, config->args, "-dvodb");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -dvodb");
-        return false;
-    }
-
-    psString tess_id = psMetadataLookupStr(&status, config->args, "-tess_id");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -tess_id");
-        return false;
-    }
-
-    psString end_stage = psMetadataLookupStr(&status, config->args, "-end_stage");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -end_stage");
         return false;
     }
@@ -1302,23 +1301,4 @@
     }
 
-    // if this is a detrend image don't put it in the chip queue (and we're
-    // done)
-    if (detrend) {
-        psFree(newExp);
-
-        // set the state for the newExp to stop
-        if (!pxnewExpSetState(config, exp_id, "stop")) {
-            // rollback
-            if (!psDBRollback(config->dbh)) {
-                psError(PS_ERR_UNKNOWN, false, "database error");
-            }
-            psError(PS_ERR_UNKNOWN, false, "failed to change newExp.state for exp_id: %s", exp_id);
-            return false;
-        }
-
-        return true;
-    }
-
-
     // set the state for the newExp to stop
     if (!pxnewExpSetState(config, exp_id, "stop")) {
@@ -1330,4 +1310,11 @@
         psFree(newExp);
         return false;
+    }
+
+    // if this is a detrend image don't put it in the chip queue (and we're
+    // done)
+    if (detrend) {
+        psFree(newExp);
+        return true;
     }
 
