Fix. UnboundLocalError: local variable kwargs referenced before assignment