clean up translate function