modified to check for current error (returning non-json object)