add exit function, not sure if works