fix an out-of-bounds error. Looks like multi-segments messages are still buggy