Index: trunk/Ohana/src/opihi/dvo/detrend.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/detrend.c	(revision 2598)
+++ trunk/Ohana/src/opihi/dvo/detrend.c	(revision 2798)
@@ -12,6 +12,6 @@
   double trange;
   int TypeSelect, CCDSelect, FilterSelect;
-  char *Filter, *Type;
-  int type, mode, CCD;
+  char *Filter;
+  int Type, mode, CCD;
   int NVALUE;
   float *value;
@@ -66,26 +66,11 @@
   if (N = get_argument (argc, argv, "-type")) {
     remove_argument (N, &argc, argv);
-    Type = strcreate (argv[N]);
+    Type = get_image_type (argv[N]);
+    if (Type == T_UNDEF) {
+      fprintf (stderr, "ERROR: invalid image type %s\n", argv[N]);
+      return (FALSE);
+    }
     remove_argument (N, &argc, argv);
     TypeSelect = TRUE;
-  }
-  type = TYPE_NONE;
-  if (TypeSelect) {
-    if (!strncasecmp (Type, "obj", 3)) {
-      type = TYPE_OBJECT;
-    }
-    if (!strncasecmp (Type, "bias", 4)) {
-      type = TYPE_BIAS;
-    }
-    if (!strncasecmp (Type, "dark", 4)) {
-      type = TYPE_DARK;
-    }
-    if (!strncasecmp (Type, "flat", 4)) {
-      type = TYPE_FLAT;
-    }
-    if (type == TYPE_NONE) {
-      fprintf (stderr, "invalid image type %s\n", Type);
-      return (FALSE);
-    }
   }
 
@@ -173,5 +158,5 @@
     if (FilterSelect && (strcasecmp (pimage[i].filter, Filter))) continue;
     if (CCDSelect && (pimage[i].ccd != CCD)) continue;
-    if (TypeSelect && (pimage[i].type != type)) continue;
+    if (TypeSelect && (pimage[i].type != Type)) continue;
 
     /* assign correct value */
