fixing spurious output that produced invalid json