fix delay code, this almost makes the previous commit obsolete, but the previous commit is still good for defending against race conditions