fix a reference error "response is not defined"; improve parse_json method;