added prettyJson output and a debug utility function