implemented codeword decoding