Implemented next() and some more changes