added safe spawning