encoder implementation compiling but not working