Updated decoding code