Hopefully fixing a string index out of range error.