adding on-exit feature