refactor multiplexer