refactoring of exceptions