Re-wrote d3 script