Fix "UnboundLocalError: local variable 'dep' referenced before assignment"