Fixed the next() and prev() methods