Replace the var in the while with
var %result $instok(%result,$mid(%dollars,$calc( [ %stuff ] * [ %length ] ),3),$calc($numtok(%result,44)+1),39) | dec %length