move canvas function to canvas.js