updates to avoid PHP fatal errors when response is not an oject