refactoring around child spawn