code changed to allow json and html generation