simplify the code by dealing with the exception first, then removing it