adding missing parts (mostly the decode part)