added the grade function