bug fixes on grade.cpp