do_openorder refactor