Cleaning table_to_json code