Use charAt instead of substring