A fleshed out getNext, hopefully it works.