fixing the Decode function