Possible implementation for next().