fix bug of not initialized lastItemIndex.