reorganizig code in function, more tests with d3.js