Macro to gosub in dial

I have to change my dialcode from macro to gosub so script works again.
Works fine with macro in v.1.4 but not in v.11
Call works fine, but hangup after 1 sec after goes back to context.

tfntocallout=xxxxxx;
phonenumber=xxxxxxx;
agentpin=1234;
agentid=1221;
timeleft=2000;
Dial(SIP/${phonenumber}@${tfntocallout},55,grU(agscreen^${agentpin}^${agentid})L(${timeleft}));
// Want to stop script running here when call is connected.

context agscreen{
s => {
	Wait(0.2);
	acceptcall=;
	Read(acceptcall,kkhotline/agent-login-pin,7);
	if(${acceptcall} = ${arg1}) {
		NoOp(${ok});
		Return;
	} else {
		Set(GOSUB_RESULT=CONTINUE);
		NoOp(${ok});
	Return;
	}
  }
}

AEL hasn’t used macros since version 1.4. Attempts to use Macros are actually implemented as Gosub’s, with a caveat that the emulation may not be perfect.

the problem is that after the call is connected so continues asterisk run the code rather than wait until the call is finished.
Is there a code for this?