index and as_json improvement