Moved main script from index.html to its own javascript file