Fix #11 by using charAt rather than [] to access string chars