Decode function