IE9 compatability

I don't know about other versions, but my version of IE9 doesn't support string characters using array indices.

Replaced "text[...]" with "text.charAt(...)" which fixed the issue for me.