Add function to decode term_code