Encoder refactor