Added logging, moved script out of index.html