diff --git a/src/RNAseq_sen1D.nf b/src/RNAseq_sen1D.nf
index 13269ddaa2bdc6fc6c12b51d10796ffefa8bb368..167e0461ad7c0ac8dad2c1617d7f3ad5181aeace 100644
--- a/src/RNAseq_sen1D.nf
+++ b/src/RNAseq_sen1D.nf
@@ -156,47 +156,81 @@ fi
 """
 }
 
-/*                      bams sorting                                    */
+/*                      bams spliting                                     */
 
-process sort_bam {
-  tag "$bam.baseName"
-  cpus 4
+process split_bam {
+  tag "$pair_id"
+  cpus 2
+  input:
+    set pair_id, file(bam) from bam_files
 
+  output:
+    set pair_id, "*_forward.bam" into forward_bam_files
+    set pair_id, "*_reverse.bam" into reverse_bam_files
+  script:
 """
-samtools sort -@ ${task.cpus} -O BAM -o ${bam.baseName}_sorted.bam ${bam}
+samtools view -hb -F 0x10 ${bam} > ${pair_id}_forward.bam &
+samtools view -hb -f 0x10 ${bam} > ${pair_id}_reverse.bam
 """
 }
 
-/*                      bams indexing                                     */
+/*                      bams sorting                                    */
 
-process index_bam {
-  tag "$bam.baseName"
+process sort_bam_forward {
+  tag "$pair_id"
+  cpus 4
+  publishDir "results/mapping/bams/", mode: 'copy'
   input:
-    file bam from sorted_bam_files
+    set pair_id, file(bam) from forward_bam_files
+
   output:
-    file "*bam*" into indexed_bam_file
+    set pair_id, "*_sorted.bam" into forward_sorted_bam_files
+
   script:
 """
-samtools index ${bam}
+samtools sort -@ ${task.cpus} -O BAM -o ${pair_id}_forward_sorted.bam ${bam}
 """
 }
+process sort_bam_reverse {
+  tag "$pair_id"
+  cpus 4
+  publishDir "results/mapping/bams/", mode: 'copy'
+  input:
+    set pair_id, file(bam) from reverse_bam_files
 
+  output:
+    set pair_id, "*_sorted.bam" into reverse_sorted_bam_files
 
-/*                      bams spliting                                     */
+  script:
+"""
+samtools sort -@ ${task.cpus} -O BAM -o ${pair_id}_reverse_sorted.bam ${bam}
+"""
+}
 
-process split_bam {
-  tag "$bam.baseName"
-  cpus 2
+/*                      bams indexing                                     */
 
+process index_bam_forward {
+  tag "$pair_id"
+  publishDir "results/mapping/bams/", mode: 'copy'
   input:
-    file bam from indexed_bam_file
+    set pair_id, file(bam) from forward_sorted_bam_files
+  output:
+    set pair_id, "*bam*" into forward_indexed_bam_file
+  script:
+"""
+samtools index ${bam}
+"""
+}
 
+process index_bam_reverse {
+  tag "$pair_id"
+  publishDir "results/mapping/bams/", mode: 'copy'
+  input:
+    set pair_id, file(bam) from reverse_sorted_bam_files
   output:
-    file "*_forward.bam*" into forward_bam_files
-    file "*_reverse.bam*" into reverse_bam_files
+    set pair_id, "*bam*" into reverse_indexed_bam_file
   script:
 """
-samtools view -hb -F 0x10 ${bam} > ${bam}_forward.bam &
-samtools view -hb -f 0x10 ${bam} > ${bam}_reverse.bam
+samtools index ${bam}
 """
 }