Index: /trunk/ppStack/src/ppStackLoop.c
===================================================================
--- /trunk/ppStack/src/ppStackLoop.c	(revision 19564)
+++ /trunk/ppStack/src/ppStackLoop.c	(revision 19565)
@@ -844,5 +844,5 @@
     float totExposure = 0.0;            // Total exposure time
     for (int i = 0; i < num; i++) {
-        if (!inputMask->data.U8[i]) {
+        if (inputMask->data.U8[i]) {
             continue;
         }
@@ -854,25 +854,23 @@
             // Copy astrometry over
             wcsDone = true;
-            if (inRO) {
-                pmHDU *inHDU = pmHDUFromCell(inRO->parent); // Template HDU
-                pmHDU *outHDU = pmHDUFromCell(outRO->parent); // Output HDU
-                pmChip *outChip = outRO->parent->parent; // Output chip
-                pmFPA *outFPA = outChip->parent; // Output FPA
-                if (!outHDU || !inHDU) {
-                    psWarning("Unable to find HDU at FPA level to copy astrometry.");
+            pmHDU *inHDU = pmHDUFromCell(inRO->parent); // Template HDU
+            pmHDU *outHDU = pmHDUFromCell(outRO->parent); // Output HDU
+            pmChip *outChip = outRO->parent->parent; // Output chip
+            pmFPA *outFPA = outChip->parent; // Output FPA
+            if (!outHDU || !inHDU) {
+                psWarning("Unable to find HDU at FPA level to copy astrometry.");
+            } else {
+                if (!pmAstromReadWCS(outFPA, outChip, inHDU->header, 1.0)) {
+                    psErrorClear();
+                    psWarning("Unable to read WCS astrometry from input FPA.");
+                    wcsDone = false;
                 } else {
-                    if (!pmAstromReadWCS(outFPA, outChip, inHDU->header, 1.0)) {
+                    if (!outHDU->header) {
+                        outHDU->header = psMetadataAlloc();
+                    }
+                    if (!pmAstromWriteWCS(outHDU->header, outFPA, outChip, WCS_TOLERANCE)) {
                         psErrorClear();
-                        psWarning("Unable to read WCS astrometry from input FPA.");
+                        psWarning("Unable to write WCS astrometry to output FPA.");
                         wcsDone = false;
-                    } else {
-                        if (!outHDU->header) {
-                            outHDU->header = psMetadataAlloc();
-                        }
-                        if (!pmAstromWriteWCS(outHDU->header, outFPA, outChip, WCS_TOLERANCE)) {
-                            psErrorClear();
-                            psWarning("Unable to write WCS astrometry to output FPA.");
-                            wcsDone = false;
-                        }
                     }
                 }
