             getReferences(child)
             getChildren(child)
 
-    path = share.getWordTemplatePath(filename)
-    docx = new DocxGen().loadFromFile(path, {async: false, parser: angularParser})
-    docx.setTags(data)
-    docx.applyTags()
-    docx.output({type: "string"})
+    return data
+
 
 # GENOTOXICITY REPORT ----------------------------------------------------------
-genotoxWordReport = (tbl_id, filename) ->
-
-    getData = () ->
-        tbl = Tables.findOne(tbl_id)
-        d =
-            "monographAgent": tbl.monographAgent
-            "volumeNumber": tbl.volumeNumber
-            "hasTable": true
-            "table": tbl
-
-        vals = GenotoxEvidence
-            .find({tbl_id: tbl_id}, {sort: {sortIdx: 1}})
-            .fetch()
-
-        for val in vals
-            val.reference = Reference.findOne(_id: val.referenceID)
-            share.setGenotoxWordFields(val)
-
-        d.nonMammalianInVitro = _.filter(vals, (v) -> return v.dataClass == "Non-mammalian in vitro")
-        d.mammalianInVitro = _.filter(vals, (v) -> return v.dataClass == "Mammalian and human in vitro")
-        d.animalInVivo = _.filter(vals, (v) -> return v.dataClass == "Animal in vivo")
-        d.humanInVivo = _.filter(vals, (v) -> return v.dataClass == "Human in vivo")
-        return d
-
-    data = getData()
-    path = share.getWordTemplatePath(filename)
-    docx = new DocxGen().loadFromFile(path, {async: false, parser: angularParser})
-    docx.setTags(data)
-    docx.applyTags()
-    docx.output({type: "string"})
+genotoxWordReport = (tbl_id) ->
+
+    tbl = Tables.findOne(tbl_id)
+    d =
+        "monographAgent": tbl.monographAgent
+        "volumeNumber": tbl.volumeNumber
+        "hasTable": true
+        "table": tbl
+
+    vals = GenotoxEvidence
+        .find({tbl_id: tbl_id}, {sort: {sortIdx: 1}})
+        .fetch()
+
+    for val in vals
+        val.reference = Reference.findOne(_id: val.referenceID)
+        share.setGenotoxWordFields(val)
+
+    d.nonMammalianInVitro = _.filter(vals, (v) -> return v.dataClass == "Non-mammalian in vitro")
+    d.mammalianInVitro = _.filter(vals, (v) -> return v.dataClass == "Mammalian and human in vitro")
+    d.animalInVivo = _.filter(vals, (v) -> return v.dataClass == "Animal in vivo")
+    d.humanInVivo = _.filter(vals, (v) -> return v.dataClass == "Human in vivo")
+    return d
 
 
 Meteor.methods
     downloadWordReport: (tbl_id, filename) ->
         tbl = Tables.findOne(tbl_id)
+        template = ReportTemplate.findOne({filename: filename})
         switch tbl.tblType
             when "Exposure Evidence"
-                fn = exposureWordReport
+                data = exposureWordReport(tbl_id)
             when "Epidemiology Evidence"
-                fn = epiWordReport
+                data = epiWordReport(tbl_id, template.epiSortOrder)
             when "Animal Bioassay Evidence"
-                fn = animalWordReport
+                data = animalWordReport(tbl_id)
             when "Genetic and Related Effects"
-                fn = genotoxWordReport
+                data = genotoxWordReport(tbl_id)
             when "Mechanistic Evidence Summary"
-                fn = mechanisticWordReport
+                data = mechanisticWordReport(tbl_id)
             else
                 return console.error("unknown table type: " + tbl.tblType)
-        fn(tbl_id, filename)
+
+        path = share.getWordTemplatePath(filename)
+        docx = new DocxGen().loadFromFile(path, {async: false, parser: angularParser})
+        docx.setTags(data)
+        docx.applyTags()
+        return docx.output({type: "string"})
 
     monographAgentEpiReport: (d) ->
         epiWordReportMultiTable(d.templateFN, d.monographagent, d.volumenumber)

    return createWordReport(filename, data)

# ANIMAL BIOASSAY REPORT -------------------------------------------------------
animalWordReport = (tbl_id, filename) ->

    getData = () ->
        tbl = Tables.findOne(tbl_id)
        studies = AnimalEvidence
            .find({tbl_id: tbl_id}, {sort: {sortIdx: 1}})
            .fetch()

        for study in studies
            study.reference = Reference.findOne(_id: study.referenceID)
            share.setAnimalWordFields(study)

        d =
            "monographAgent": tbl.monographAgent
            "volumeNumber": tbl.volumeNumber
            "hasTable": true
            "table": tbl
            "studies": studies

        return d

    data = getData()
    path = share.getWordTemplatePath(filename)
    docx = new DocxGen().loadFromFile(path, {async: false, parser: angularParser})
    docx.setTags(data)
    docx.applyTags()
    docx.output({type: "string"})


# MECHANISTIC REPORT -----------------------------------------------------------
mechanisticWordReport = (tbl_id, filename) ->

    getReferences = (obj) ->
        refs = Reference.find({_id: {$in: obj.references}}).fetch()

    docx.applyTags()
    return docx.output({type: "string"})

epiWordReport = (tbl_id, epiSortOrder) ->
    switch epiSortOrder
        when "Reference"
            return getEpiDataByReference(tbl_id)
        when "Organ-site"
            return getEpiDataByOrganSite(tbl_id)
        else
            console.error("unknown epiSortOrder")

epiWordReportMultiTable = (filename, monographAgent, volumeNumber) ->
    epiSortOrder = ReportTemplate.findOne({filename: filename}).epiSortOrder
