While we're here, we should consider moving this logic to a separate method. Notice how it's duplicated in the rescue clause.