Index: /trunk/Ohana/src/opihi/dvo/imbox.c
===================================================================
--- /trunk/Ohana/src/opihi/dvo/imbox.c	(revision 10929)
+++ /trunk/Ohana/src/opihi/dvo/imbox.c	(revision 10930)
@@ -3,10 +3,12 @@
 int imbox (int argc, char **argv) {
   
-  int i, j, status, InPic, flipped, Nextend;
+  int i, j, Nskip, status, InPic, flipped, Nextend;
   Vector Xvec, Yvec;
   double r, d, x[4], y[4], Rmin, Rmax, Rmid;
   Header header;
   Coords coords;
+  Coords mosaic;
   Graphdata graphmode;
+  FILE *f;
 
   if (!style_args (&graphmode, &argc, argv, 0)) return FALSE;
@@ -18,12 +20,8 @@
   SetGraph (graphmode);
 
-  if (!gfits_read_header (argv[1], &header)) {
+  f = fopen (argv[1], "r");
+  if (f == NULL) {
     gprint (GP_ERR, "file not found\n");
     return (FALSE);
-  }
-  
-  Nextend = 0;
-  if (header.Naxes == 0) {
-    gfits_scan (&header, "NEXTEND", "%d", 1, &Nextend);
   }
   
@@ -36,11 +34,10 @@
   ALLOCATE (Yvec.elements, float, 8);
 
-  for (i = Nextend ? 0 : -1; i < Nextend; i++) {
-    if (Nextend) {
-      gfits_read_Xheader (argv[1], &header, i);
-    }
-    if (!GetCoords (&coords, &header)) {
-      gprint (GP_ERR, "can't get WCS info from header\n");
-      return (TRUE);
+  while (gfits_fread_header (f, &header)) {
+    if (!GetCoords (&coords, &header)) goto skip;
+    if (!strcmp (&coords.ctype[4], "-DIS")) {
+      mosaic = coords;
+      RegisterMosaic (&mosaic);
+      goto skip;
     }
     x[0] = 0;               y[0] = 0;
@@ -84,7 +81,10 @@
       PlotVector (8, Yvec.elements);
     }
+  skip:
+    Nskip = gfits_matrix_size (&header);
+    fseek (f, Nskip, SEEK_CUR); 
+    gfits_free_header (&header);
   }
-
-  gfits_free_header (&header);
+  fclose (f);
   free (Xvec.elements);
   free (Yvec.elements);
