codec refactoring