added `wait_for_variable` to work more reliable under slow network conditions