slideshow js refactored