finished grading algorithm