Added findPrev function as well