Factor js out of .html file and into index.js