Created a delay function