Replace the `then` functions with wait functions

This should help with periodic errors