charAt instead of [] for better compatibility