Moved js code from index.html to its own js file