fixed d3 loop bug