cleaned up grader.js and reduced redundancy