It might be better to use `window.setTimeout` and `window.clearTimeout` to have less global variables/functions.