refactor betLanguageById function