I'm well aware of the fact, that wait is a "special" function and I'm even able to rewrite a simple for loop. I'm even not insisting on fixing this. JCL will know if a fix makes sense or does not.
The thing is that I want to understand what's going on - out of curiosity.
Always learn from history, to be sure you make the same mistakes again...