diff --git a/steps/structure_function.cwl b/steps/structure_function.cwl
new file mode 100644
index 0000000000000000000000000000000000000000..434d75f0513a3a4b421f9624bb0c4078382728e3
--- /dev/null
+++ b/steps/structure_function.cwl
@@ -0,0 +1,62 @@
+class: CommandLineTool
+cwlVersion: v1.0
+$namespaces:
+  lofar: 'https://git.astron.nl/eosc/ontologies/raw/master/schema/lofar.owl'
+  sbg: 'https://www.sevenbridges.com/'
+id: structure_function
+baseCommand:
+  - python3
+  - /usr/local/bin/getStructure_from_phases.py
+inputs:
+  - format: 'lofar:#H5Parm'
+    id: h5parmFile
+    type: File
+    inputBinding:
+      position: 0
+    doc: List of h5parm files
+  - default: 'target'
+    id: solset
+    type: string?
+    inputBinding:
+      position: 0
+      prefix: '--solset'
+    doc: Input solset name
+  - default: 'phase000'
+    id: soltab
+    type: string?
+    inputBinding:
+      position: 0
+      prefix: '--soltab'
+    doc: Name of the soltab
+  - default: 'POINTING'
+    id: outbasename
+    type: string?
+    inputBinding:
+      position: 0
+      prefix: '--outbasename'
+    doc: Namebase of the output files
+outputs:
+  - id: structure_plot
+    doc: Output plot
+    type: File
+    outputBinding:
+      glob: $(inputs.outbasename+'_structure.png')
+  - id: structure_txt
+    doc: Output text
+    type: File
+    outputBinding:
+      glob: $(inputs.outbasename+'_structure.txt')
+  - id: log
+    type: File[]
+    outputBinding:
+      glob: 'structure_function*.log'
+label: structure_function
+requirements:
+  - class: InlineJavascriptRequirement
+hints:
+  - class: DockerRequirement
+    dockerPull: lofareosc/prefactor:HBAcalibrator
+stdout: structure_function.log
+stderr: structure_function_err.log
+$schema:
+  - 'https://git.astron.nl/eosc/ontologies/raw/master/schema/lofar.owl'
diff --git a/workflows/prefactor_target.cwl b/workflows/prefactor_target.cwl
index b1ab44771de0d879150e593ff54262623c766282..f2082880e94595b2ae42814022a8af0cabe0d7b0 100644
--- a/workflows/prefactor_target.cwl
+++ b/workflows/prefactor_target.cwl
@@ -242,6 +242,7 @@ outputs:
   - id: inspection
     outputSource:
       - prep/inspection
+      - finalize/inspection
     type: 'File[]'
     linkMerge: merge_flattened
     'sbg:x': 2000
@@ -404,6 +405,7 @@ steps:
     out:
       - id: msout
       - id: solutions
+      - id: inspection
       - id: logfiles
     run: ./prefactor_target/finalize.cwl
     label: finalize
diff --git a/workflows/prefactor_target/finalize.cwl b/workflows/prefactor_target/finalize.cwl
index f4949a3706604404023ef2dbee393b1da7ab5c0d..1b3ab90517337f3c404cb666c4b49f7b80190226 100644
--- a/workflows/prefactor_target/finalize.cwl
+++ b/workflows/prefactor_target/finalize.cwl
@@ -46,22 +46,30 @@ outputs:
     outputSource:
       - apply_gsmcal/msout
     type: 'Directory[]'
-    'sbg:x': 1000
+    'sbg:x': 1300
     'sbg:y': 0
   - id: solutions
     outputSource:
       - h5parm_pointingname/outh5parm
     type: File
-    'sbg:x': 1000
+    'sbg:x': 1300
     'sbg:y': 200
   - id: logfiles
     outputSource:
       - concat_logfiles_applygsm/output
       - concat_logfiles_solutions/output
+      - concat_logfiles_structure/output
     type: 'File[]'
     linkMerge: merge_flattened
-    'sbg:x': 1000
+    'sbg:x': 1300
     'sbg:y': 800
+  - id: inspection
+    outputSource:
+      - structure_function/structure_plot
+    type: 'File[]?'
+    linkMerge: merge_flattened
+    'sbg:x': 1300
+    'sbg:y': 500
 steps:
   - id: add_missing_stations
     in:
@@ -169,6 +177,27 @@ steps:
     label: h5parm_pointingname
     'sbg:x': 400
     'sbg:y': 200
+  - id: structure_function
+    in:
+      - id: h5parmFile
+        source: write_solutions/outh5parm
+      - id: solset
+        default: 'target'
+      - id: soltab
+        source:
+          - skymodel_source
+          - gsmcal_step
+        valueFrom: $(self.join(''))
+      - id: outbasename
+        source: get_targetname/targetname
+    out:
+      - id: structure_plot
+      - id: structure_txt
+      - id: log
+    run: ../../steps/structure_function.cwl
+    label: structure_function
+    'sbg:x': 500
+    'sbg:y': 300
   - id: concat_logfiles_applygsm
     in:
       - id: file_list
@@ -200,6 +229,22 @@ steps:
     label: concat_logfiles_solutions
     'sbg:x': 500
     'sbg:y': 500
+  - id: concat_logfiles_structure
+    in:
+      - id: file_list
+        linkMerge: merge_flattened
+        source:
+          - structure_function/log
+          - structure_function/structure_txt
+      - id: file_prefix
+        source: get_targetname/targetname
+        valueFrom: $(self+'_structure')
+    out:
+      - id: output
+    run: ../../steps/concatenate_files.cwl
+    label: concat_logfiles_structure
+    'sbg:x': 950
+    'sbg:y': 500
   - id: get_targetname
     in:
       - id: msin