fixing the calculate grade logic