d3 refactor