Added getNext() function.