replaced spawn with Thread::spwan