refactor d3