fixed strange race condition