diff --git a/samtools.wdl b/samtools.wdl
index 0d43015794579ba27f7ce58d7d3b144ea778f58f..ab2c84e2882603fa56f364110c0fe67d588a6f2a 100644
--- a/samtools.wdl
+++ b/samtools.wdl
@@ -36,10 +36,9 @@ task Index {
     }
 
     output {
-        File index = select_first(flatten([[bamIndexPath], glob(sub(basename(bamFile), "\.bam$", "") + "*.bai")]))
         IndexedBamFile outputBam = object {
           file: bamFile,
-          index: index
+          index: select_first(flatten([[bamIndexPath], glob(sub(basename(bamFile), "\.bam$", "") + "*.bai")]))
         }
     }
 }