refactor for remote execution