added cursors for top-left bottom-right and put the context setup at the top of the functions