alter output function to store result in a json file