added logic for slideshow