use encoder factory