added semaphore. must test