refactored grader.js for cleaner solution