changin to semaphore