fix canvas size calculation