fix unbundLocalError: local variable  referenced before assignment