added D3 library and refactored code