Partial fix of race condition