Refactor d3