catching possible race conditions