error condition refactoring