smart errors refactored