fixed error checking issue in doRequest()