Added JSON generation logic