clarify encoding logic