me: factor out recovery code