re-write in d3