Error refactoring