optimize generator