added basic encoder code