updated functional protocol to be compatible with generators