Somehow the codeExecuted function gets executed before the code being executed in the console is done running. Specifically canvas.clear()