decoder implementation