Changed logic in translate function