make an encoder and a function as well