added http request error handling