refactoring encoding ...