Use charAt instead of indexOf