Update grade calculation logic