implemented algorithum for translation