refactor error codes