Fixed next() to handle errors