Fix index out range if slider is changed.