control of child processes, refactor