Refactor fetch_json