diff --git a/bwa.wdl b/bwa.wdl
index 01dae9b479aedf7d8a28d2fac66b4f3de11972cc..3dd7883bd9920d83edd3d9250e9fbad29e496f51 100644
--- a/bwa.wdl
+++ b/bwa.wdl
@@ -29,7 +29,7 @@ task Mem {
         String? readgroup
 
         Int threads = 4
-        String memory = "~{5 + ceil(size(indexFiles, "G"))}G"
+        String memory = "~{5 + ceil(size(bwaIndex.indexFiles, "G"))}G"
         String picardXmx = "4G"
         Int timeMinutes = 1 + ceil(size([read1, read2], "G") * 200 / threads)
         # A mulled container is needed to have both picard and bwa in one container.