language detection moved to separate method