update script to output JSON, test condition