rewrote exits, refactored some code