refactor the focusSlide function