diff --git a/src/mpsd_software_manager/mpsd_software.py b/src/mpsd_software_manager/mpsd_software.py
index 13c2e4a2bf11a577d1f61b9673e0dd009c071df1..dc113bd2fd107e76cc11d41a37940536416689e8 100755
--- a/src/mpsd_software_manager/mpsd_software.py
+++ b/src/mpsd_software_manager/mpsd_software.py
@@ -1137,26 +1137,29 @@ def get_root_dir() -> Path:
     # check if the root_dir is not already initialized
     script_call_dir = Path.cwd()
     init_file = script_call_dir / config_vars["init_file"]
-    if not init_file.exists():
-        for parent_folder in script_call_dir.parents:
-            init_file = parent_folder / config_vars["init_file"]
-            if init_file.exists():
-                script_call_dir = parent_folder
-                return script_call_dir
-        logging.getLogger("print").info(
-            "Error: Couldnt find MPSD software instance"
-            "in the current directory or any parent directory. \n"
-            f"Directory {str(script_call_dir)} is not a MPSD software instance. \n"
-            "Please run 'mpsd-software init' to "
-            "initialise the software instance here, \n"
-            "or switch to a directory which is already initialised.\n \n"
-            f"Hint: Look for the hidden file {config_vars['init_file']}"
-            " to check if a directory is initialised"
-        )
-        sys.exit(1)
-    else:
+    if init_file.exists():
         return script_call_dir
 
+    # if not, look for the init file in the parent directories
+    for parent_folder in script_call_dir.parents:
+        init_file = parent_folder / config_vars["init_file"]
+        if init_file.exists():
+            script_call_dir = parent_folder
+            return script_call_dir
+
+    # if not found in any parent directory, exit with an error message
+    logging.getLogger("print").info(
+        "Error: Couldnt find MPSD software instance"
+        "in the current directory or any parent directory. \n"
+        f"Directory {str(script_call_dir)} is not a MPSD software instance. \n"
+        "Please run 'mpsd-software init' to "
+        "initialise the software instance here, \n"
+        "or switch to a directory which is already initialised.\n \n"
+        f"Hint: Look for the hidden file {config_vars['init_file']}"
+        " to check if a directory is initialised"
+    )
+    sys.exit(1)
+
 
 def main():
     """Execute main entry point."""