Slight changes to onLeave in Merit.js