Refactored code and fixed language selector