Refactor error object