Added code to handle the case in which the response is null.