decode function

Decoding step