diff --git a/fsl/utils/filetree/query.py b/fsl/utils/filetree/query.py
index 56ba6cc4991b30bb47aad00ed513cc3868465951..a2e215c848558f304e62c61ba529614bd05038f0 100644
--- a/fsl/utils/filetree/query.py
+++ b/fsl/utils/filetree/query.py
@@ -373,7 +373,7 @@ def scan(tree : FileTree) -> List[Match]:
 
             filename = tree.update(**variables).get(template)
 
-            if not op.isfile(tree.update(**variables).get(template)):
+            if not op.isfile(filename):
                 continue
 
             matches.append(Match(filename, template, tree, variables))