added semaphore support