modularized the graph code, app.js mostly empty