preliminary json output refactoring complete