Just one small comment: rather than call $numtok() repeatedly, you should set the value to a variable:

Code:
var %i = 1, %count = $numtok(%chans,44)
while (%i !> %count) {
  ...
}