shorten the encode function