         let range = pdfWriter.addHeadline(string, style: .H4, backgroundBoxColor: backgroundBoxColor, calculationOnly: true)
         let funcCall = DocumentStructure.FunctionCall.addH4(string: string, backgroundBoxColor: backgroundBoxColor)
         let docNode = DocumentStructure.DocumentElement(functionCall: funcCall, pageRange: range)
-        document.document.append(docNode)
+        document.documentElements.append(docNode)
         return range
     }
     

        // Start with a clean slate
        self.pdfWriter = initializePDFWriter(0)
        var pageIndex = -1
        for (var i = 0; i < document.document.count; i++) {
            let docElement = document.document[i]
            // page number is: let pageNumber = pageIndex + docElement.pageRange.location
            docElement.executeFunctionCall(pdfWriter, calculationOnly: true)
            pageIndex += (docElement.pageRange.location + docElement.pageRange.length)

        let range = pdfWriter.addHeadline(string, style: .H3, backgroundBoxColor: backgroundBoxColor, calculationOnly: true)
        let funcCall = DocumentStructure.FunctionCall.addH3(string: string, backgroundBoxColor: backgroundBoxColor)
        let docNode = DocumentStructure.DocumentElement(functionCall: funcCall, pageRange: range)
        document.documentElements.append(docNode)
        return range
    }
    
