decoder refactoring