Add grade function almost working