fixed handleResponse - check for invalid response object