logic for demux by value
demux first draft is working