grade function done