implemented free monad for protocol operations.