decode function completed