error messages refactoring