Complete multithread version