fix error in generating grades