optimize the use of canvas size