refactored encoded part