refactor for separation of de/encode