diff --git a/atdb/taskdatabase/services/algorithms.py b/atdb/taskdatabase/services/algorithms.py
index 1c22571b41f85476510b1c214b9b8794aba90eaf..de2afb9aac74c575b9a92e424921b07d6476d2f1 100644
--- a/atdb/taskdatabase/services/algorithms.py
+++ b/atdb/taskdatabase/services/algorithms.py
@@ -1131,19 +1131,18 @@ def construct_summary(task):
 
     summary_flavour = get_summary_flavour(task)
     logger.info(f'summary_flavour = {summary_flavour}')
-    html = ""
 
     # construct the appropriate summary html
     if summary_flavour == SummaryFlavour.DEFAULT.value:
-        html = construct_default_summary(task)
+        return construct_default_summary(task)
 
     elif summary_flavour == SummaryFlavour.IMAGING_COMPRESSION.value:
-        html = construct_imaging_summary(task)
+        return construct_imaging_summary(task)
 
     elif summary_flavour == SummaryFlavour.LINC_CALIBRATOR.value:
-        html = construct_linc_summary(task)
+        return construct_linc_summary(task)
 
     elif summary_flavour == SummaryFlavour.LINC_TARGET.value:
-        html = construct_linc_summary(task)
+        return construct_linc_summary(task)
 
-    return html
+    return None
diff --git a/atdb/taskdatabase/views.py b/atdb/taskdatabase/views.py
index 53462130567c347260750f4ef2867b34c2646c69..bac558c2ef8d49eea882f8f42a7c143b682026ce 100644
--- a/atdb/taskdatabase/views.py
+++ b/atdb/taskdatabase/views.py
@@ -27,6 +27,8 @@ from django_tables2.views import SingleTableMixin
 from django.shortcuts import render, redirect, reverse
 from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
 from django.contrib.admin.views.decorators import staff_member_required
+
+from django.template.loader import get_template
 from xhtml2pdf import pisa
 from io import BytesIO
 
@@ -1715,17 +1717,7 @@ def GetSummaryHtml(request, sas_id):
         # use a trick to be able to use the existing task based code
         queryset = Task.objects.filter(sas_id=sas_id)
         task = queryset[0]
-        logger.info(task)
-        # this would be the django template way of combining a html template with context.
-        # but that didn't add any of the styling, so I did it the basic way (see below).
-        # TODO: remove the commented out code later
-
-        # template = get_template("taskdatabase/validation/summary.html")
-        # summary_html = algorithms.construct_summary(task)
-        # context = {'task': task, 'my_summary': summary_html}
-        # html = template.render(context)
 
-        # add some basic layout without using the summary.html template
         head_html="""
             <head>
                <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
@@ -1733,24 +1725,11 @@ def GetSummaryHtml(request, sas_id):
             </head>
         """
 
-        body_html = """
-            <html>
-                <body>
-                    <div class="container-fluid details-container">
-                        <div class='card'><table>
-                            <div class="card-body">
-                                <table class="table table-striped">
-        """
-        logger.info(body_html)
-        # create the core html
+        template = get_template("taskdatabase/validation/summary.html")
         summary_html = algorithms.construct_summary(task)
-        logger.info(summary_html)
-        # close all the tags
-        footer_html = "</table></div></div></div></body></html>"
+        context = {'task': task, 'my_summary': summary_html}
+        html = head_html + template.render(context)
 
-        # combine the html sections
-        html = head_html + body_html + summary_html + footer_html
-        logger.info(html)
         return HttpResponse(html)
 
     except Exception as error:
@@ -1775,36 +1754,23 @@ def GetSummaryPdf(request, sas_id):
         task = queryset[0]
 
         # add some basic layout without using the summary.html template
-        head_html = """
+        head_html="""
             <head>
                <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
                <link href='https://fonts.googleapis.com/css?family=Raleway' rel='stylesheet' type='text/css'>
             </head>
         """
 
-        body_html = """
-            <html>
-                <body>
-                    <div class="container-fluid details-container">
-                        <div class='card'><table>
-                            <div class="card-body">
-                                <table class="table table-striped">
-        """
-
-        # create the core html
+        template = get_template("taskdatabase/validation/summary.html")
         summary_html = algorithms.construct_summary(task)
-
-        # close all the tags
-        footer_html = "</table></div></div></div></body></html>"
-
-        # combine the html sections
-        html = head_html + body_html + summary_html + footer_html
+        context = {'task': task, 'my_summary': summary_html}
+        html = head_html + template.render(context)
 
         # Create a BytesIO object to receive the PDF data
         result = BytesIO()
 
         # Convert HTML to PDF
-        # TODO: fonts zijn fout in dev (ook op production?)
+        # TODO: fonts zijn fout, is daar nog iets aan te doen?
         pdf = pisa.pisaDocument(BytesIO(html.encode("UTF-8")), result)
         pdf_name = sas_id + '_summary.pdf'
         if not pdf.err: