complete the slideshow function