refactored carousel js code to separate lib file