might stop working. Need to fix this! We can either mutex the whole thing which is slow (this is how it was before the race condition was introduced) or find a different solution.