added/tested working grading algorithm