fixing bug in decoding