Can we refactor this to avoid so much code duplication in these two, very similar, conditions?