Define next function before it was used.

We had some trouble to get glob.js work on [trireme](https://github.com/apigee/trireme) when ```next``` was called before it was defined. Anyway, it looks much better for me and JSLint too.