[lib] encodes name, accounts for possible error in result set