generalized and improved language selector