Refactored ResizeCanvas functionality