further refactoring and tranlation