added exit and checks before we exit to save files