fixed exiting issues