Fixed the delay function.