fixed race condition, I hope