Refactored index.html and main.js