add demultiplexing code