fix illegal string offset problem