diff --git a/viewer/itkpd-interface/lib/RecursiveComponentsSynchronizer.py b/viewer/itkpd-interface/lib/RecursiveComponentsSynchronizer.py
index a25f1892735f67c3ad61296403ccd645fd8f3d85..19b362afc04cd815d9323d52294ea2203e4a3da7 100755
--- a/viewer/itkpd-interface/lib/RecursiveComponentsSynchronizer.py
+++ b/viewer/itkpd-interface/lib/RecursiveComponentsSynchronizer.py
@@ -436,7 +436,7 @@ class RecursiveComponentsSynchronizer(PDInterface.PDInterface):
                                 f'syncTestRun(): failed in getting {attachment.get("type")} attachment for a test run (ITkPD code: {pd_tr_doc.get("id")}): retry up to {self.max_try} times...'
                             )
 
-                    if i == max_try - 1:
+                    if i == self.max_try - 1:
                         logger.warning(
                             f'syncTestRun(): failed in getting {attachment.get("type")} attachment for a test run (ITkPD code: {pd_tr_doc.get("id")}). Given up'
                         )