Refactor to use a return channel for clearer semantics.