Refactored app to minimize code in index.html and allow the app to be more modular