refactors spawn process