Debugged next() and implemented prev()