made carousel function better