Fix a bug with next() helper method