Refactor errors