more efficient

Hand written with some mistakes ( fixed )

1. typo. I wrote chatAt() in line 25 instead of charAt()

2. typo. I missed back parentheses in line 25.

3. Logical statement in while loop. I used "OR" instead of
"AND", which is a mistake. As a result, the while loop would cause index
out of bounds exception.