Multithreading non-optimal version