Cleaner code in mouse position event handler