refactored spawning