Refactor translation code