Fix to save selected state even with pagination