encoder refactor continued