Simplified implementation of Generate with index