better encode, branch stuff