Fixed an error where characterAtIndex would throw out of bounds