changed algorithm of language detect