Changed delay function