make the wait.js more readable and safer