Use charAt instead of indexing into strings to support IE