updated to use new util.Encode