Added error handling code to index.html