refactored transcode mechanism to hide header data