diff --git a/src/nf_modules/samtools/main.nf b/src/nf_modules/samtools/main.nf
index 1a402ba50b5f243c0258323f8c511b2f1f7821e3..3c940314ee9e5017d7c7e602bb7d6cb598672ac0 100644
--- a/src/nf_modules/samtools/main.nf
+++ b/src/nf_modules/samtools/main.nf
@@ -18,7 +18,7 @@ process index_fasta {
 
   script:
 """
-if gzip -t file.gz; then
+if gzip -t ${fasta}; then
   zcat ${fasta} > ${fasta.simpleName}.fasta
   samtools faidx ${params.index_fasta}  ${fasta.simpleName}.fasta
 else