refactor the way the application exits and exceptions are caught