Updated next() and previous() methods