now augmenting user-supplied onEnter and onLeave functions instead of passing them straight through