Move the `retry` and `checkState` commands out of both branches of the `if`?