changes to logic in wait