refactored server.js, index.js, canvas.js