Added encoder code