Convert to test and function based loop.