Index: /trunk/psastro/src/psastroChipAstrom.c
===================================================================
--- /trunk/psastro/src/psastroChipAstrom.c	(revision 16070)
+++ /trunk/psastro/src/psastroChipAstrom.c	(revision 16071)
@@ -49,10 +49,7 @@
 		    readout->data_exists = false;
 		    psLogMsg ("psastro", 3, "insufficient rawstars (%ld) or refstars (%ld)", 
-			    rawstars->n, refstars->n);
+			      rawstars->n, refstars->n);
 		    continue;
 		} 
-
-		char *filename = NULL;
-		char *chipname = psMetadataLookupStr (NULL, chip->concepts, "CHIP.NAME");
 
 		// save WCS and analysis metadata in update header
@@ -60,5 +57,5 @@
 
 		// XXX update the header with info to reflect the failure
-		if (!psastroOneChip (fpa, chip, refstars, rawstars, recipe, updates)) {
+		if (!psastroOneChipGrid (fpa, chip, refstars, rawstars, recipe, updates)) {
 		    readout->data_exists = false;
 		    psLogMsg ("psastro", 3, "failed to find a solution\n");
@@ -66,4 +63,12 @@
 		    continue;
 		}
+		// XXX update the header with info to reflect the failure
+		if (!psastroOneChipFit (fpa, chip, refstars, rawstars, recipe, updates)) {
+		    readout->data_exists = false;
+		    psLogMsg ("psastro", 3, "failed to find a solution\n");
+		    psFree (updates);
+		    continue;
+		}
+
 		pmAstromWriteWCS (updates, fpa, chip, NONLIN_TOL);
 		psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.HEADER",  PS_DATA_METADATA, "psastro header stats", updates);
@@ -71,4 +76,8 @@
 
 		if (psTraceGetLevel("psastro.dump") > 0) {
+
+		    char *filename = NULL;
+		    char *chipname = psMetadataLookupStr (NULL, chip->concepts, "CHIP.NAME");
+
 		    psStringAppend (&filename, "rawstars.ch.%s.dat", chipname);
 		    psastroDumpStars (rawstars, filename);
@@ -85,4 +94,20 @@
     }
 
+    // psastroDumpCorners ("corners.chipAstrom.dat", input->fpa);
+
+# if (0)
+    if (!psastroFixChipsTest (config, recipe)) {
+	psError(PSASTRO_ERR_UNKNOWN, false, "failed to align problematic chips");
+	return false;
+    }
+# endif
+
+    if (!psastroFixChips (config, recipe)) {
+	psError(PSASTRO_ERR_UNKNOWN, false, "failed to align problematic chips");
+	return false;
+    }
+
+    // psastroDumpCorners ("corners.fixChips.dat", input->fpa);
+
     psFree (view);
     return true;
