modified sequence of functions in char_exit()