Fixed strange race condition