improved spawning, anti stuck function