I am not able to reproduce my errors, because i can not see exactly when the error occurs.

I have made a rss newstracker which downloads newsitems and displays them to the channel when new newsitems are posted. I need to replace some characters to human readable characters and on this line I have had several crashes.Well actually it isn't a crash but mirc uses 100% cpu time for quite a long time, ctrl break still works! I will try to get a reproductive example a.s.a.p. but for know you will have to do with my code:

;Mirc crashes on the return statement. I do stress out that it does not crash most of the times, that is why I think it is caused by a large string/line from the rss feed

alias web.parser {
if ( < isin $1- ) {
var %i = $pos($1-,<,0) | var %ii = 1
while ( %ii <= %i ) {
set %fok.1. [ $+ [ %ii ] ] $calc($pos($1-,&lt;, %ii ) - 1)
set %fok.2. [ $+ [ %ii ] ] $calc($pos($1-,&gt;, %ii ) + 4)
if ( %ii = 1 ) { var %totaal = $ $+ left($ $+ 1-, $+ %fok.1.1 $+ ) }
if ( %ii != 1 ) { var %ff = %fok.2. [ $+ [ $calc(%ii - 1) ] ]
var %totaal = %totaal $ $+ mid($ $+ 1-, $+ %ff $+ , $+ $calc(%fok.1. [ $+ [ %ii ] ] - %ff +1 ) $+ )
}
if ( %ii == %i ) { var %totaal = %totaal $ $+ right($ $+ 1-,- $+ $calc(%fok.2. [ $+ [ %ii ] ] - 1) $+ ) }
inc %ii
}
.unset %fok.1.*
.unset %fok.2.*
tokenize 32 $replace($replace($eval(%totaal,3),$chr(32),$chr(0160)),$chr(0160) $+ $chr(0160),$chr(0160))
}
;the next line is the line which causes my problems
return $replace($1-,&rsquo;,',á,á,ï,ï,é,é,ö,ö,ë,ë,$chr(38) $+ $chr(35) $+ 039 $+ $chr(59),$chr(39),$chr(38) $+ quot $+ $chr(59),$chr(34),$chr(38) $+ amp $+ $chr(59),$chr(38),&#8221;,$chr(34),&#8217;,',&#8220;,$chr(34))
}