Adding multi-threaded capability to outer loop