reorganize code, use d3.json