use apply to handle arbitrary arguments to next()