Updaated the way getNext and getFirst work