Refactor to use D3 factory