Updates to grade calculation logic