a little bit of refactoring of channel.flow code