refactoring codec usage