change exits to exceptions