diff --git a/scripts/parse_led.py b/scripts/parse_led.py
index 2dacc0e..f6394dc 100755
--- a/scripts/parse_led.py
+++ b/scripts/parse_led.py
@@ -5,6 +5,101 @@
 import yaml
 from inflection import underscore
 
+
+def check_led_priority(led_name, value, priority_dict):
+
+    if led_name in priority_dict:
+        if value != priority_dict[led_name]:
+            # Priority for a particular LED needs to stay SAME
+            # across all groups
+            ofile.close()
+            os.remove(ofile.name)
+            raise ValueError(
+                "Priority for [" + led_name + "] is NOT same across all groups"
+            )
+    else:
+        priority_dict[led_name] = value
+
+    return 0
+
+
+def generate_file_single_led(ifile, led_name, list_dict, priority_dict, ofile):
+
+    value = list_dict.get("Priority")
+
+    check_led_priority(led_name, value, priority_dict)
+
+    action = "phosphor::led::Layout::Action::" + str(
+        list_dict.get("Action", "Off")
+    )
+    dutyOn = str(list_dict.get("DutyOn", 50))
+    period = str(list_dict.get("Period", 0))
+    priority = "phosphor::led::Layout::Action::" + str(
+        list_dict.get("Priority", "Blink")
+    )
+
+    ofile.write('        {"' + underscore(led_name) + '",')
+    ofile.write(action + ",")
+    ofile.write(dutyOn + ",")
+    ofile.write(period + ",")
+    ofile.write(priority + ",")
+
+    ofile.write("},\n")
+
+    return 0
+
+
+def generate_file_single_group(ifile, group, priority_dict, ofile):
+    # This section generates an std::unordered_map of LedGroupNames to
+    # std::set of LEDs containing the name and properties
+    led_dict = ifile[group]
+
+    group_priority = 0
+    has_group_priority = "Priority" in led_dict
+
+    if has_group_priority:
+        group_priority = led_dict["Priority"]
+        # we do not want to enumerate this as a led group
+        del led_dict["Priority"]
+
+    ofile.write(
+        '   {"'
+        + "/xyz/openbmc_project/led/groups/"
+        + underscore(group)
+        + '"'
+        + ",{ "
+        + str(group_priority)
+        + ",\n"
+        + "{\n"
+    )
+
+    for led_name, list_dict in list(led_dict.items()):
+        generate_file_single_led(
+            ifile, led_name, list_dict, priority_dict, ofile
+        )
+
+    ofile.write("   }}},\n")
+
+    return 0
+
+
+def generate_file(ifile, ofile):
+    # Dictionary having [Name:Priority]
+    priority_dict = {}
+
+    ofile.write("/* !!! WARNING: This is a GENERATED Code..")
+    ofile.write("Please do NOT Edit !!! */\n\n")
+
+    ofile.write("static const phosphor::led::GroupMap")
+    ofile.write(" systemLedMap = {\n\n")
+
+    for group in list(ifile.keys()):
+        generate_file_single_group(ifile, group, priority_dict, ofile)
+    ofile.write("};\n")
+
+    return 0
+
+
 if __name__ == "__main__":
     script_dir = os.path.dirname(os.path.realpath(__file__))
     parser = argparse.ArgumentParser()
@@ -41,57 +136,5 @@
     with open(yaml_file, "r") as f:
         ifile = yaml.safe_load(f)
 
-    # Dictionary having [Name:Priority]
-    priority_dict = {}
-
     with open(os.path.join(args.outputdir, "led-gen.hpp"), "w") as ofile:
-        ofile.write("/* !!! WARNING: This is a GENERATED Code..")
-        ofile.write("Please do NOT Edit !!! */\n\n")
-
-        ofile.write("static const phosphor::led::GroupMap")
-        ofile.write(" systemLedMap = {\n\n")
-        for group in list(ifile.keys()):
-            # This section generates an std::unordered_map of LedGroupNames to
-            # std::set of LEDs containing the name and properties
-            led_dict = ifile[group]
-            ofile.write(
-                '   {"'
-                + "/xyz/openbmc_project/led/groups/"
-                + underscore(group)
-                + '",{\n'
-            )
-
-            # Some LED groups could be empty
-            if not led_dict:
-                ofile.write("   }},\n")
-                continue
-
-            for led_name, list_dict in list(led_dict.items()):
-                value = list_dict.get("Priority")
-                if led_name in priority_dict:
-                    if value != priority_dict[led_name]:
-                        # Priority for a particular LED needs to stay SAME
-                        # across all groups
-                        ofile.close()
-                        os.remove(ofile.name)
-                        raise ValueError(
-                            "Priority for ["
-                            + led_name
-                            + "] is NOT same across all groups"
-                        )
-                else:
-                    priority_dict[led_name] = value
-
-                ofile.write('        {"' + underscore(led_name) + '",')
-                ofile.write(
-                    "phosphor::led::Layout::Action::"
-                    + str(list_dict.get("Action", "Off"))
-                    + ","
-                )
-                ofile.write(str(list_dict.get("DutyOn", 50)) + ",")
-                ofile.write(str(list_dict.get("Period", 0)) + ",")
-                priority = str(list_dict.get("Priority", "Blink"))
-                ofile.write("phosphor::led::Layout::Action::" + priority + ",")
-                ofile.write("},\n")
-            ofile.write("   }},\n")
-        ofile.write("};\n")
+        generate_file(ifile, ofile)
