errors refactoring