add semaphore in writing