Fixed running out of bounds of the array which we shrinking.