Fixed UnboundLocalError
Fixed UnboundLocalError