Create canvas and context in separate function