fixing semaphores