Added error check in web.js