Simplify the `wait` function.