I would keep the delay as a separate function just as you have it. All I would alter is:
1. Add some hysteresis around the detection comparator.
2. Increase the values of R1, R4 to conserve some current, also makes the hysteresis easier.
3. Why is R7, 300k, seems high?