continued refactoring of carousel script