change the wait function to then
change wait to then