Refactored the mouse trail calculation