could encode function