better semaphore processing