Fixed a bug in the delay code