Changed encoder code