uses String.charAt instead of String[] for IE compatibility