refactor main.js and result.js