Fixed an edge case issue that caused an array index out of bounds. I saw it a few times. I finally understand it.