correct carousel error in onclick function