move code to get canvas and store mouse position outside of window.onload function