This resolves the race condition (I think)