fixed a bug with with exiting the program