major refactoring with d3.nest()