rework of code to support json output