Updated the language selector and optimized the code