adding error handling to XHR request
hotfixing this