new (broken) implementation using a semaphore