implemented multinomial decoder