Refactor of infinite scroll for slideshow