refactor child process spawning