def convert(value, row):
    '''Step 0: If none then POB2 = 77'''
    if not row['ctzx']:
        return '99'
    
    v = row['ctzx'].strip().lower()
    
    try:
        ''' Step 1:
            a. Remove the punctuation from POBX (currently only comma and period)
            b. Remove YY from POBX
            c. Replace zero with O
            d. Check to see if value in crosswalk
        '''
        v_1 = re.sub(' yy|[,.]', '', v)
        v_1 = v_1.replace('0', '0')
        
    
        return crosswalk['default'].convert(v_1).upper()
    
    except ConvertError:
        ''' Step 2:
            a. If CTZX is less than 3 digits than it was not in the crosswalk then return 77
            b. If space or comma proceeds the last two digits than check crosswalk for last two digits
            c. If two digits are found but not in crosswalk then return 77
        '''
        
        l = len(v)
        
        if l < 3:
            return '99'
    
        if v[l-3] in (',', ' '):
            try:
                return crosswalk['default'].convert(v[l-2:l]).upper()
            except ConvertError:
                return '99'
        else:
            try:
                #switch steps three and for to make more efficient (but will make code more complex
                ''' Step 3: Check to see if two commas, if match than check crosswalk for that value. '''
                if re.search('(?<=,).*(?=,)', v):
                    v = re.search('(?<=,).*(?=,)', v).group()
                    return crosswalk['default'].convert(v.strip()).upper()
                else:
                    ''' Step 4: Match all text after a comma and check to see if that value is in crosswalk.'''
                    v = re.search('(?<=,).*', v)
                    v = v.group() if v else ''
                    return crosswalk['default'].convert(v.strip()).upper()
            except ConvertError:
                ''' Step 5: All lookups in crosswalk failed, write report and set CTZX = 77 '''
                log.write('ctz2', [row['id'], row['rapstatex'], row['ctzx'], "key_1 not in xwalk"])
                return '99'