Panic: Slice bounds out of range when indexing

What is the solution to this bug?