Index: /trunk/ppImage/src/ppImageReplaceBackground.c
===================================================================
--- /trunk/ppImage/src/ppImageReplaceBackground.c	(revision 18216)
+++ /trunk/ppImage/src/ppImageReplaceBackground.c	(revision 18217)
@@ -28,5 +28,9 @@
     psMaskType maskVal  = options->satMask | options->badMask | options->flatMask | options->blankMask;
 
+    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
+    psMetadataAddU8 (recipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", maskVal);
+
     float meanValue = psMetadataLookupF32 (&status, recipe, "SKY_MEAN");
+    bool replaceSkyMean = psMetadataLookupBool (&status, recipe, "REPLACE.SKY_MEAN");
 
     // iterate over the cells and readout for this chip
@@ -68,5 +72,5 @@
 		for (int ix = 0; ix < image->numCols; ix++) {
 		    if (!(mask->data.U8[iy][ix] && maskVal)) continue;
-		    if (1) {
+		    if (replaceSkyMean) {
 			image->data.F32[iy][ix] = meanValue;
 		    } else {
