better logic for determining the language