added declaration of semaphore