Just for the avoidance of doubt .... you want the consequence to occur when the whole group is fleeing, right?
Because if that's true, there's probably an easier way to do it. You can ignore dead members of the group because they are, erm, dead, so try something like
? "fleeing _x2" count units grp1 == counts units grp1: goto "consequence"
Have a go on the forum search function too - this has come up before though I can't remember the answer.
I haven't really looked at your script because I'm not really a scripter, but I think if a line starts with
?
you've got to have
:
later on in the line, followed by whatever you want to happen if the condition is true.