fix scope issues with callbacks and waitUntilReady()