Made waiting on the correct number for the semaphore.