Refactored the grading logic into a grade utility class.