ErrorHandler and refactor