add some error handling
d3 function edits