simplify enter and exit handlers