Fire events based on information in the return load

def fire_ret_load(self, load):
        '''
        Fire events based on information in the return load
        '''
        if load.get('retcode') and load.get('fun'):
            if isinstance(load['fun'], list):
                # Multi-function job
                if isinstance(load['retcode'], list):
                    multifunc_ordered = True
                else:
                    multifunc_ordered = False

                for fun_index in range(0, len(load['fun'])):
                    fun = load['fun'][fun_index]
                    if multifunc_ordered:
                        if (len(load['retcode']) > fun_index and
                                load['retcode'][fun_index] and
                                fun in SUB_EVENT):
                            # Minion fired a bad retcode, fire an event
                            self._fire_ret_load_specific_fun(load, fun_index)
                    else:
                        if load['retcode'].get(fun, 0) and fun in SUB_EVENT:
                            # Minion fired a bad retcode, fire an event
                            self._fire_ret_load_specific_fun(load, fun_index)
            else:
                # Single-function job
                if load['fun'] in SUB_EVENT:
                    # Minion fired a bad retcode, fire an event
                    self._fire_ret_load_specific_fun(load)