simplified and removed semaphore