Fix the issue when rotating the last index.