First multithread working version