Hi Steve
ofcourse i should do that instead, sometimes the answer is so obvious that you dont see it :-D... im already using sourceText.length for turning on/off layers so i dont know why i didn't think of this.
Thank you Steve. much appreciated for getting me in the right direction
The error was just a generic invalid numeric value:
"invalid numeric result (divide by zero?)."
it makes sense since it tries to return a value from a string character that doesnt exists.
down to 0 errors now :-)