optimize auto set language logic