dealt with race conditions