add auto_switch and unix codes