Refactored translation function