Refactoring of the mouseClickedHandler class