Refactored grader.js to fix error