updated code to convert to new JSON structure after processing