1) writeTable accepts json 2) writeTable only gets called once 3) use $.extend to replace loop.