refactored slideshow js code for better stucture