slideshow working, attempt to optimize code