added handling of non-json responses