refactoring for slideshow