options.index can now accept a function

corrected implementation using next callback