Refactored mouse hover code