implement more efficient version of the multiplexer