Isn't this if redundant with the first if statement where you check if res.nil? and res.body.empty?