fix constructor race condition