Fixed a bug in nextSlice