change the structure and refactor the translate method