changed exit function