(Hopefully) fixed TOCTOU Race condition