Improve my d3js management