refactor errors