Added JSON writing