diff --git a/.ci/generateIndex.py b/.ci/generateIndex.py
index ded9dd4524245bacad746386ea13f4dca84cfc6c..a833641fb496941b222c7e4122acc95e0853d8ca 100644
--- a/.ci/generateIndex.py
+++ b/.ci/generateIndex.py
@@ -10,9 +10,8 @@ cardDirs = ["internal", "external"]
 sections, ignore = get_sections(cardDirs)
 localIndexArr, orderArr = get_indexArr(sections)
 
-# Index contains the generated content, init it with an empty container
-index = ''
-index += '\n<div class="index-box-container">\n'
+index = generate_index_top()
+
 whiteList = ''
 
 for folder in cardDirs:
@@ -26,17 +25,8 @@ for folder in cardDirs:
 
         for d in dirs:
             if d[0] != "." and d not in ignore and has_subdirs(folder + "/" + d):
-                # get the index of the section
-                indexS = sections.index(d)
-                maxOrder = 0
-
-                if len(localIndexArr[indexS]) == 0:
-                    localIndexArr[indexS] = ["\n"]
-
                 # walk through the folders with all the cards
-                for root, dirs, files in os.walk(folder+"/"+d):
-                    for file in files:
-                        folderFlag, localIndexArr, whiteList = core(file, localroot, root, folder, localIndexArr, orderArr, indexS, whiteList, folderFlag, maxOrder)
+                folderFlag, localIndexArr, whiteList = core(localroot, folder, localIndexArr, orderArr, whiteList, folderFlag, d, sections)
 
 localIndexArr = sort_sections(sections, localIndexArr, orderArr)
 index = generate_index(index, sections, localIndexArr)