replaced all to_json calls with as_json