diff --git a/zesje/pregrader.py b/zesje/pregrader.py
index 42b4541058df9fc24fe21dcf7a66acc32e1bca98..22500020d9f0386505f0197133d5657e0f3cdb0e 100644
--- a/zesje/pregrader.py
+++ b/zesje/pregrader.py
@@ -17,18 +17,18 @@ from zesje.database import db, Solution, ProblemWidget
 from zesje.images import guess_dpi, get_box, fix_corner_markers
 
 
-def add_feedback_to_solution(page, page_img, corner_keypoints):
+def add_feedback_to_solution(exam, page, page_img, corner_keypoints):
     """
     Adds the multiple choice options that are identified as marked as a feedback option to a solution
 
     Params
     ------
+    exam: the current exam
     page_img: image of the page
     barcode: data from the barcode on the page
     corner_keypoints: locations of the corner keypoints
     """
-    problem_widgets = ProblemWidget.query.filter(ProblemWidget.page == page).all()
-    problems_on_page = [widget.problem for widget in problem_widgets]
+    problems_on_page = [problem for problem in exam.problems if problem.widget.page == page]
 
     fixed_corner_keypoints = fix_corner_markers(corner_keypoints, page_img.shape)
 
@@ -43,13 +43,15 @@ def add_feedback_to_solution(page, page_img, corner_keypoints):
             box = (mc_option.x, mc_option.y)
 
             if box_is_filled(box, page_img, top_left_point):
-                sol.feedback.append(mc_option.feedback)
-                db.session.commit()
+                feedback = mc_option.feedback
 
                 if mc_option.label:
-                    sol.feedback.text = mc_option.label
+                    feedback.text = mc_option.label
                     db.session.commit()
 
+                sol.feedback.append(feedback)
+                db.session.commit()
+
 
 def box_is_filled(box, page_img, corner_keypoints, marker_margin=72/2.54, threshold=225, cut_padding=0.1, box_size=11):
     """
diff --git a/zesje/scans.py b/zesje/scans.py
index a7436eaec63060a289d9354974548a6b6f6b5c49..e82223d00a4d05ebb70e2db76900080b11691c5c 100644
--- a/zesje/scans.py
+++ b/zesje/scans.py
@@ -338,8 +338,8 @@ def process_page(image_data, exam_config, output_dir=None, strict=False):
     else:
         return True, "Testing, image not saved and database not updated."
 
-    update_database(image_path, barcode)
-    add_feedback_to_solution(barcode.page, image_array, corner_keypoints)
+    exam = update_database(image_path, barcode)
+    add_feedback_to_solution(exam, barcode.page, image_array, corner_keypoints)
 
     if barcode.page == 0:
         description = guess_student(
@@ -408,7 +408,7 @@ def update_database(image_path, barcode):
 
     db.session.commit()
 
-    return sub, exam
+    return exam
 
 
 def decode_barcode(image, exam_config):