Moved the delay function out of main.