refactoring error message handling - 2 - continued