refactor open_tok bits