fix bug: config object was not passed to encode object