Save last index if tab is changed