modified GTM code for wait_re