use charAt instead of string.split