make encode and decode configurable