diff --git a/src/nf_modules/ucsc/main.nf b/src/nf_modules/ucsc/main.nf
index ff3fbe2770b4f2629f483e50500b8728eecd8e56..914697810aa34fe4ebee759ad93a624cf0076cbc 100644
--- a/src/nf_modules/ucsc/main.nf
+++ b/src/nf_modules/ucsc/main.nf
@@ -53,7 +53,9 @@ process wig_to_bedgraph {
 
   script:
 """
-wigToBedGraph ${wig} ${wig.simpleName}.bg
+wigToBigWig ${wig} ${wig.simpleName}.bw
+bigWigToBedGraph ${wig.simpleName}.bw ${wig.simpleName}.bg
+rm ${wig.simpleName}.bw
 """
 }
 
@@ -75,8 +77,12 @@ process wig2_to_bedgraph2 {
 
   script:
 """
-wigToBedGraph ${wig_a} ${wig_a.simpleName}.bg
-wigToBedGraph ${wig_b} ${wig_b.simpleName}.bg
+wigToBigWig ${wig_a} ${wig_a.simpleName}.bw
+bigWigToBedGraph ${wig_a.simpleName}.bw ${wig_a.simpleName}.bg
+rm ${wig_a.simpleName}.bw
+wigToBigWig ${wig_b} ${wig_b.simpleName}.bw
+bigWigToBedGraph ${wig_b.simpleName}.bw ${wig_b.simpleName}.bg
+rm ${wig_b.simpleName}.bw
 """
 }