fixing problem that can't correctly exit