Fix a 'slice bounds out of range' error