difficulties with semaphore