Add multithreading and mutex