Refactored mouseevent