Needs to check if $response is an object before trying to access an attribute