Reworked code to allow multiple channels