Refactor into D3.js