Re-wrote code to free JSON data after use