decode function works