rewrote encoder to inherit from coder
rewrote encoder to update model after coding