Refactoring around canvas and mouse listener