refactored main.js and index.html