bugfix: don't return the next index