Updated threading to fix Semaphore issue