Added input multiplexer to handle inputs on each stage.