yep… you could rewrite this whole block like this:

```js
var $carousel = $(document.activeElement)

$carousel
  .carousel('pause')
  .carousel(
    /next|prev/.test(type) ? type :
    type == 'first'             ? 0 : nItems - 1
  )
  .carousel('cycle')

e.preventDefault()
```