remove an unnecessary variable and added a semaphore_destroy.