Refactoring of get_available_languages