refactor flow_to_remote