Reduced carousel funciton even further. Moved it to a separate script file to ensure easier maintainability.