fixing handleResponse when response is undefined