fixed at_exit block