diff --git a/steps/check_filtered_MS_array.cwl b/steps/check_filtered_MS_array.cwl
new file mode 100644
index 0000000000000000000000000000000000000000..6eac322cf06fc0b3d7d47c762ebb67a098f738dd
--- /dev/null
+++ b/steps/check_filtered_MS_array.cwl
@@ -0,0 +1,25 @@
+id: check_filtered_MS_array
+label: check_filtered_MS_array
+class: ExpressionTool
+
+cwlVersion: v1.1
+inputs:
+    - id: input
+      type: Directory[]
+
+outputs:
+    - id: output
+      type: Directory[]
+
+expression: |
+  ${
+    if (inputs.input.length == 0) {
+        throw new Error("No MS files meet the minimum unflagged fraction set by min_unflagged_fraction")
+    } else {
+        return {'output': inputs.input}
+    }
+  }
+
+
+requirements:
+  - class: InlineJavascriptRequirement
diff --git a/steps/merge_array.cwl b/steps/merge_array.cwl
index 14fcd046bb4072028b3cc5de584575b0e002f7e8..833be080c1694891ed4dd3d6c8adc94d2b8ba798 100644
--- a/steps/merge_array.cwl
+++ b/steps/merge_array.cwl
@@ -3,14 +3,14 @@ label: merge_array
 class: ExpressionTool
 
 cwlVersion: v1.1
-inputs: 
+inputs:
     - id: input
       type:
         - type: array
           items:
             - type: array
               items: Directory
-outputs: 
+outputs:
     - id: output
       type: Directory[]
 
@@ -28,4 +28,4 @@ expression: |
 
 
 requirements:
-  - class: InlineJavascriptRequirement
\ No newline at end of file
+  - class: InlineJavascriptRequirement
diff --git a/workflows/prefactor_target/gsmcal.cwl b/workflows/prefactor_target/gsmcal.cwl
index 94aeef683e32e5a81d193e0db3f6db401d550d4a..e6b89b0660cb4cc5d0c3d200981a7f3eeb54170a 100644
--- a/workflows/prefactor_target/gsmcal.cwl
+++ b/workflows/prefactor_target/gsmcal.cwl
@@ -463,10 +463,18 @@ steps:
     label: merge_array_files
     'sbg:x': 1000
     'sbg:y': 100
+  - id: check_filtered_MS_array
+    in:
+      - id: input
+        source: merge_array/output
+    out:
+      - id: output
+    run: ../../steps/check_filtered_MS_array.cwl
+    label: check_filtered_MS_array
   - id: calibrate_target
     in:
       - id: msin
-        source: merge_array/output
+        source: check_filtered_MS_array/output
       - id: skymodel
         source: make_sourcedb_target/sourcedb
       - id: do_smooth