grade function now working