use charCodeAt instead of charAt when possible