This is the only real change. I moved all of the side effects into `then`.