renamed parser to main.js; reorganized code