fix a bug of next()