setmode enter & leave