working through d3 function