refactor do not copy entry around when doing encoding