Having issues with the script scheduler

I am trying to create a script to get data usage from simple queues. I created two simple queues with differnet IPs and then run the following script in my terminal which shows the correct log output.

:global numberOfQueues ([:len [/queue simple find]] - 1)
:for i from=0 to=$numberOfQueues do={ 
    :global targetIP [/queue/simple/get number=$i target]
    /log info $targetIP
}

However when I go to system > Script and add the same exact script and try to run it I get an error “executing script test from winbox failed. please check it manually”

I noticed that when I have just one simple queue, this error is not presented but the logs are also empty. What am I doing wrong here?

Funziona quasi casualemnte:
/queue simple
:foreach q in=[find] do={
:log info “$[get $q target]”
}
or more shortly:

/queue simple print where [:log info $target]

Did more digging. The issue with the for loop and seems to be a bug. Foreach solved the issue. Thanks