fix context of wait sub-functions execution