Multithreading now working perfectly