Added detect_lang method