diff --git a/steps/get_targetname.cwl b/steps/get_targetname.cwl
new file mode 100644
index 0000000000000000000000000000000000000000..9c999be81045fae929190a57bcb4ce20ebb009ae
--- /dev/null
+++ b/steps/get_targetname.cwl
@@ -0,0 +1,55 @@
+class: CommandLineTool
+cwlVersion: v1.0
+$namespaces:
+  lofar: 'https://git.astron.nl/eosc/ontologies/raw/master/schema/lofar.owl'
+  sbg: 'https://www.sevenbridges.com/'
+id: get_targetname
+baseCommand:
+  - python3
+inputs:
+    - id: msin
+      type: Directory[]
+      doc: MS to compare with
+      inputBinding:
+        position: 0
+
+arguments:
+  - '-c'
+  - |
+    import sys
+    import json
+    from getTargetName import main as getTargetName
+    
+    mss = sys.argv[1:]
+
+    output = getTargetName(mss)
+
+    targetName = output['targetName']
+    cwl_output = {"targetName": targetName}
+
+    with open('./out.json', 'w') as fp:
+        json.dump(cwl_output, fp)
+        
+outputs:
+  - id: targetname
+    type: string
+    outputBinding:
+        loadContents: true
+        glob: 'out.json'
+        outputEval: $(JSON.parse(self[0].contents).targetName)
+  - id: logfile
+    type: File[]
+    outputBinding:
+      glob: 'get_targetname*.log'
+        
+requirements:
+  - class: InlineJavascriptRequirement
+  - class: InitialWorkDirRequirement
+    listing:
+      - entry: $(inputs.msin)
+        writable: true
+hints:
+  - class: DockerRequirement
+    dockerPull: lofareosc/prefactor:HBAcalibrator
+stdout: get_targetname.log
+stderr: get_targetname_err.log
diff --git a/steps/h5parm_pointingname.cwl b/steps/h5parm_pointingname.cwl
index 21a1b2633c37ac6831fa725e790cdb95eeaab1ff..30ecb0cf1940c57d0b9fae3167980bf646a68f96 100644
--- a/steps/h5parm_pointingname.cwl
+++ b/steps/h5parm_pointingname.cwl
@@ -1,47 +1,55 @@
 class: CommandLineTool
 cwlVersion: v1.0
 $namespaces:
+  lofar: 'https://git.astron.nl/eosc/ontologies/raw/master/schema/lofar.owl'
   sbg: 'https://www.sevenbridges.com/'
 id: h5parm_pointingname
 baseCommand:
   - python3
   - /usr/local/bin/h5parm_pointingname.py
 inputs:
-  - id: h5parm
+  - format: 'lofar:#H5Parm'
+    id: h5parmFile
     type: File
     inputBinding:
-      position: 1
-    doc: H5parm whose pointing direction should be corrected the solutions should be transferred.
-  - id: solsetName
+      position: 0
+    doc: List of h5parm files
+  - default: 'target'
+    id: solsetName
     type: string?
     inputBinding:
       position: 0
       prefix: '--solsetName'
-    doc: Name of the input h5parm solution set
-  - id: pointing
+    doc: Input solset name
+  - default: 'POINTING'
+    id: pointing
     type: string?
     inputBinding:
       position: 0
       prefix: '--pointing'
-    doc: Name of the output h5parm solution set
+    doc: Name of the pointing
 outputs:
   - id: outh5parm
+    doc: Output h5parm
     type: File
     outputBinding:
-      glob: $(inputs.h5parm.basename)
+      glob: $(inputs.h5parmFile.basename)
+    format: lofar:#H5Parm
   - id: log
     type: File[]
     outputBinding:
-      glob: 'h5parm_name*.log'
-stdout: h5parm_name.log
-stderr: h5parm_name_err.log
+      glob: 'h5parm_pointingname*.log'
 label: h5parm_pointingname
-hints:
-  - class: DockerRequirement
-    dockerPull: 'lofareosc/prefactor:HBAcalibrator'
 requirements:
-  - class: InlineJavascriptRequirement
   - class: InitialWorkDirRequirement
     listing:
-      - entry: $(inputs.h5parm)
-        writable: true
\ No newline at end of file
+      - entry: $(inputs.h5parmFile)
+        writable: true
+  - class: InlineJavascriptRequirement
+hints:
+  - class: DockerRequirement
+    dockerPull: lofareosc/prefactor:HBAcalibrator
+stdout: h5parm_pointingname.log
+stderr: h5parm_pointingname_err.log
+$schema:
+  - 'https://git.astron.nl/eosc/ontologies/raw/master/schema/lofar.owl'
diff --git a/workflows/prefactor_target/finalize.cwl b/workflows/prefactor_target/finalize.cwl
index eca05da6e17fbbafe22a3dbf221fd9d5ebc9c656..f4949a3706604404023ef2dbee393b1da7ab5c0d 100644
--- a/workflows/prefactor_target/finalize.cwl
+++ b/workflows/prefactor_target/finalize.cwl
@@ -50,7 +50,7 @@ outputs:
     'sbg:y': 0
   - id: solutions
     outputSource:
-      - write_solutions/outh5parm
+      - h5parm_pointingname/outh5parm
     type: File
     'sbg:x': 1000
     'sbg:y': 200
@@ -77,8 +77,10 @@ steps:
         source: gsmcal_step
         valueFrom: $(self+'000')
       - id: soltab_out
-        source: gsmcal_step
-        valueFrom: $(inputs.skymodel_source+self)
+        source:
+          - skymodel_source
+          - gsmcal_step
+        valueFrom: $(self.join(''))
       - id: filter
         source: process_baselines_target
       - id: bad_antennas
@@ -106,8 +108,10 @@ steps:
       - id: databitrate
         source: compression_bitrate
       - id: correction
-        source: gsmcal_step
-        valueFrom: $(inputs.skymodel_source+self)
+        source:
+          - skymodel_source
+          - gsmcal_step
+        valueFrom: $(self.join(''))
       - id: solset
         default: 'target'
       - id: msout_name
@@ -129,8 +133,10 @@ steps:
       - id: outsolset
         default: target
       - id: insoltab
-        source: gsmcal_step
-        valueFrom: $(inputs.skymodel_source+self)
+        source:
+          - skymodel_source
+          - gsmcal_step
+        valueFrom: $(self.join(''))
       - id: input_file
         source: insolutions
       - id: squeeze
@@ -146,6 +152,23 @@ steps:
     label: write_solutions
     'sbg:x': 200
     'sbg:y': 500
+  - id: h5parm_pointingname
+    in:
+      - id: h5parmFile
+        source: write_solutions/outh5parm
+      - id: outsolset
+        default: 'target'
+      - id: solsetName
+        default: 'target'
+      - id: pointing
+        source: get_targetname/targetname
+    out:
+      - id: outh5parm
+      - id: log
+    run: ../../steps/h5parm_pointingname.cwl
+    label: h5parm_pointingname
+    'sbg:x': 400
+    'sbg:y': 200
   - id: concat_logfiles_applygsm
     in:
       - id: file_list
@@ -167,6 +190,8 @@ steps:
           - inh5parm_logfile
           - add_missing_stations/log
           - write_solutions/log
+          - get_targetname/logfile
+          - h5parm_pointingname/log
       - id: file_prefix
         default: losoto_gsmcal
     out:
@@ -175,6 +200,18 @@ steps:
     label: concat_logfiles_solutions
     'sbg:x': 500
     'sbg:y': 500
+  - id: get_targetname
+    in:
+      - id: msin
+        linkMerge: merge_flattened
+        source: msin
+    out:
+      - id: targetname
+      - id: logfile
+    run: ../../steps/get_targetname.cwl
+    label: get_targetname
+    'sbg:x': 200
+    'sbg:y': 200
 requirements:
   - class: SubworkflowFeatureRequirement
   - class: ScatterFeatureRequirement