added print_on_enter/exit function.