refactoring error message handling - 3 - continued