diff --git a/bwa.wdl b/bwa.wdl
index ffa42313dad13f0c13df6f9c77f938567c0027a0..2845c32e877bb3c617964e47ea62a2c90a347523 100644
--- a/bwa.wdl
+++ b/bwa.wdl
@@ -35,6 +35,7 @@ task index {
     Int? blockSize
     String? outputDir
     String fastaFilename = basename(fasta)
+    String outputFile = if (defined(outputDir)) then outputDir + "/" + fastaFilename else fasta
 
     command {
         set -e -o pipefail
@@ -47,7 +48,7 @@ task index {
         bwa index \
         ${"-a " + constructionAlgorithm} \
         ${"-b" + blockSize} \
-        ${outputDir + "/"}${fastaFilename}
+        ${outputFile}
     }
 
     output {