diff --git a/python_scripts/run_simstadt_from_python/variable_window_ratio.py b/python_scripts/run_simstadt_from_python/variable_window_ratio.py
index 867548acc18b5950b8b8f7b005e4acf2f3ae1b4a..48748ba81fa7eee9ba62deff6b57cbf90633db76 100644
--- a/python_scripts/run_simstadt_from_python/variable_window_ratio.py
+++ b/python_scripts/run_simstadt_from_python/variable_window_ratio.py
@@ -13,6 +13,9 @@ SIMSTADT2_GLOB = 'Desktop/SimStadt2_0.*/'
 REPO_PATH = Path.home() / 'git' / 'simstadt2' / 'TestRepository'
 PROJECT_NAME = 'Gruenbuehl'
 CITYGMLS = ['Gruenbuehl_LOD2_ALKIS_1010.gml']
+SURFACES = ['outWalls', 'pitchedRoof']
+XML_LIB_URL = 'http://www.simstadt.eu/BuildingPhysicsLibraries'
+NAMESPACE = {'': XML_LIB_URL}
 
 PROJECT_PATH = REPO_PATH / f'{PROJECT_NAME}.proj'
 PARAMS = 'params.xml'
@@ -38,31 +41,46 @@ custom_library_path = physics_processor_step / BUILDING_PHYSICS_LIBRARY
 
 physics_processor_params = physics_processor_step / PARAMS
 
-tree = et.parse(physics_processor_params)
-root = tree.getroot()
+param_tree = et.parse(physics_processor_params)
+root = param_tree.getroot()
 
 lib_node = root.find(".//object[@class='de.hft.stuttgart.simstadt2.assessment.PhysicsXmlLib']/void[@property='path']/string")
 lib_node.text = str(custom_library_path)
-tree.write(physics_processor_params)
+param_tree.write(physics_processor_params)
 ##########################################################
 
-with open(custom_library_path) as library_file:
-    content = library_file.read()
+def parse_library(library_path: Path) -> et.ElementTree:
+    et.register_namespace('', XML_LIB_URL)
+    return et.parse(library_path)
+
+lib_tree = parse_library(custom_library_path)
+
+def set_custom_window_ratio(tree: et.ElementTree, window_ratio_node: float, export_path: Path):
+    root = tree.getroot()
+    root.find('name', NAMESPACE).text = f"Custom Physics Library with Window Ratio : {window_ratio}"
+    for surface in SURFACES:
+        for node in root.findall(f'.//{surface}', NAMESPACE):
+            window_ratio_node = node.find('./windowRatio', NAMESPACE)
+            if window_ratio_node is not None:
+                window_ratio_node.text = str(window_ratio)
+    tree.write(export_path)
 
 for window_ratio in WINDOW_RATIOS:
 
     #################### Update lib with custom values ############################
 
-    new_content = re.sub(r"<name>[\w ]+</name>",
-                    f"<name>Custom Physics Library with Window Ratio : {window_ratio}</name>",
-                    content, 1)
-    # FIXME: Use et.parse instead. Because groundSurfaces shouldn't have any WindowRatio
-    new_content = re.sub(r"<windowRatio>[\d\.]+</windowRatio>",
-                     f"<windowRatio>{window_ratio}</windowRatio>",
-                     new_content)
+    set_custom_window_ratio(lib_tree, window_ratio, custom_library_path)
+
+    # new_content = re.sub(r"<name>[\w ]+</name>",
+    #                 f"<name>Custom Physics Library with Window Ratio : {window_ratio}</name>",
+    #                 content, 1)
+    # # FIXME: Use et.parse instead. Because groundSurfaces shouldn't have any WindowRatio
+    # new_content = re.sub(r"<windowRatio>[\d\.]+</windowRatio>",
+    #                  f"<windowRatio>{window_ratio}</windowRatio>",
+    #                  new_content)
 
-    with open(custom_library_path, 'w') as library_file:
-        library_file.write(new_content)
+    # with open(custom_library_path, 'w') as library_file:
+    #     library_file.write(new_content)
     #################################################################################
 
     output_files = run_workflow(find_simstadt(SIMSTADT2_GLOB), workflow_path, CITYGMLS)