Moved the threadDelay statement