Correct the sequence in the previous commit to avoid possible deadlock.