Added a nextIndex to onLeave callback

Sorry my editor removed a lot of whitespaces.