Refactored HTML and Javascript in index.html