adjusted exit logic when exiting