carousel.php refactoring