implemented code for smarter grading