Added MUX setting function
Working version refactored into new structure