restructured event handler to capture all mouse motion events